HTTPfy

405 Method Not Allowed

The resource exists but does not support the HTTP method used.

405 at a glance

Code
405
Name
Method Not Allowed
Class
4xx Client error
Status
IANA-registered standard code
Defined in
RFC 9110, Section 15.5.6
Cacheable by default
Yes, heuristically cacheable (RFC 9110 section 15.1): without Cache-Control or Expires, caches may store it and pick a freshness lifetime themselves. Send explicit Cache-Control to stay in control.

What 405 means

405 Method Not Allowed says the target resource is known but rejects this method, for example a DELETE on a read-only resource or a POST to a static file. The server must include an Allow header listing the methods it does support. 405 is heuristically cacheable.

What typically causes a 405

  • nginx answers "405 Not Allowed" to POST requests for static files.
  • Framework routes defined only for GET receiving POST (Flask, Django, Express all send 405 when the path matches but the method does not).
  • Form submissions to the wrong URL, or a missing trailing slash causing a redirect that turns POST into GET.
  • WebDAV methods (PROPFIND, MKCOL) sent to servers without WebDAV enabled.

Fix it on the server

  • Include Allow, e.g. Allow: GET, HEAD.
  • Answer OPTIONS correctly, especially for CORS preflights; a 405 on OPTIONS breaks cross-origin requests.

Fix it as a client or visitor

  • Check the API docs for the correct method and URL; send the request to the final URL rather than through a redirect.

Headers that go with 405

HeaderRole
AllowRequired: methods the resource supports.

Example response

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

{"error": "Method POST not allowed"}

Opens the HTTP headers tool with your URL filled in; it shows the status line and headers of every redirect hop.