1. HTTP (Hypertext Transfer Protocol)

  1. HTTP Status Codes

  1. 405 Method Not Allowed
    1. Writing responses (servers)
    2. Reading responses (clients)
    3. Overview table
    4. Example

405 Method Not Allowed

The 405 (Method Not Allowed) HTTP status code indicates the method is not supported by the resource. The origin server MUST generate an Allow header containing a list of the target resource's currently supported methods.

Writing responses (servers)

Every resource should have an associated set of methods that it supports (see the Allow header), and send 405 if the requested method is not one of them.

For example, if a document is hard-coded into an application, a PUT request would generate 405 Method Not Allowed since there is no way to modify the resource.

Servers should send 405 Method Not Allowed after the resource has been looked up, before method-specific routines are called.

Reading responses (clients)

This error is typically permanent, it indicates the client is trying to perform an action that doesn't make any sense.

It is possible that another sequence of methods might accomplish the same effect, if the Allow response header lists all the necessary methods. The possibility of recovering is less likely than recovering from 501 Method Not Implemented, since 405 implies that the server understands the method, it's just not applicable for this resource.

Overview table

Name
405
Message
405 Method Not Allowed
Description
The resource does not permit the requested method.
Specification
RFC 7231: HTTP/1.1 Semantics and Content ยง6.5.5. 405 Method Not Allowed

Example

HTTP/1.1 405 Method Not Allowed
Content-Type: text/plain
Allow: GET, HEAD, OPTIONS

This is a read-only resource!
HTTP/1.1 405 Method Not Allowed
Content-Type: text/plain
Allow: GET, HEAD, OPTIONS, POST

This is a hard-coded collection that supports the following methods:
- GET/HEAD: List the resources in the collection
- OPTIONS: List serialization options
- POST: Upload a new member of the collection