405 Method Not Allowed
The URL is valid, but not for the HTTP method you used. The response lists the methods that are accepted in its Allow header.
What 405 means
The server recognises the method (GET, POST, PUT, PATCH, DELETE and so on) and found the resource, but that resource does not support that method. A read-only report cannot be DELETEd; a login endpoint that takes POST has nothing to say to a GET.
The server must send an Allow header listing what the resource does support, so the response carries its own fix:
Allow: GET, HEAD, OPTIONS
A 405 is also cacheable by default, like 404. If you add a method to an endpoint and a client still sees 405, look for a cache in between.
Why you are getting it
- A redirect changed your method. You POST to
http://, to the bare domain or to a path without its trailing slash; the server answers 301 or 302; the client follows with a GET; the endpoint only takes POST. Send the request to the final URL. If you run the server, redirect with 308, which keeps the method. - Right resource, wrong level.
DELETE /orderswhere the API only supportsDELETE /orders/8123, or a POST to an item URL that only accepts PUT and PATCH. - Posting to a static file. nginx serves static files for GET and HEAD and answers 405 to a POST. This shows up when a form's
actionpoints at an HTML page, or when a request that should have been proxied to the application was matched by a staticlocationinstead. - A router with no handler for that verb. The framework found the path and no function registered for PUT, PATCH or OPTIONS on it.
- An unhandled CORS preflight. Before a cross-origin request with a JSON body or custom headers, the browser sends OPTIONS. If the server answers 405, the browser reports a CORS failure and never sends the real request.
- An HTML form with
method="put"or"delete". Forms support only GET and POST; anything else is sent as GET.
Fixing it
As a client: read Allow, then run the request with curl -i -X POST https://example.com/path and look at each hop. A Location header in the first response means a redirect is involved. Check the API reference for the method and the exact path, including the trailing slash.
As a server owner:
- Register the missing handler, or route the path to the application instead of the static file handler.
- Answer OPTIONS on routes that browsers call from other origins.
- Always send
Allow. Most frameworks build it from the route table; a hand-written 405 often forgets it. - Do not use 405 to mean "you may not do that". If the method works for some users and not for this one, the code is 403.
405 compared with 501, 403 and 404
| Code | Scope | Meaning |
|---|---|---|
| 405 Method Not Allowed | This resource | The server knows the method; this URL does not support it |
| 501 Not Implemented | The whole server | The server does not recognise or support the method anywhere |
| 403 Forbidden | This caller | The method is supported, but not for you |
| 404 Not Found | This URL | No resource, whatever the method |
Example 405 response
HTTP/1.1 405 Method Not Allowed
Allow: GET, HEAD
Content-Type: application/json
Content-Length: 86
{"error":"method_not_allowed","message":"DELETE is not supported on /reports/2026-10"}Allow is mandatory in a 405. An empty value is legal and means the resource currently accepts no methods at all.
Defined in RFC 9110, section 15.5.6.
Questions
How do I fix a 405 Method Not Allowed error?
Look at the Allow header in the response: it lists the methods the URL accepts. Then check that you are calling the exact final URL, because a redirect on the way can turn a POST into a GET. If the server is yours, add a handler for the method or correct the routing.
Why does my POST request return 405?
Most often the POST was redirected and re-sent as a GET, or it reached something that only serves GET, such as a static file or a route defined for reading only. Compare the URL you send with the one in the API documentation, including the scheme and trailing slash.
What is the difference between 405 and 501?
A 405 is about one resource: the server understands the method but this URL does not support it. A 501 is about the server as a whole: it does not implement the method for any resource.
Why do I get 405 on an OPTIONS request?
The browser sent a CORS preflight and the server has no handler for OPTIONS on that route. Enable CORS handling in the framework or proxy so that OPTIONS is answered with the allowed methods and headers.