What 405 Method Not Allowed means
405 Method Not Allowed means the target resource exists but does not support the request method. The response must include an Allow header listing the methods that are supported for that resource.
When a server should return it
- A client sends POST to an endpoint that only accepts GET.
- A DELETE is attempted on a read-only collection.
- A PUT is sent where only PATCH is implemented.
- An OPTIONS preflight hits a route that does not declare CORS methods.
Example response
HTTP/1.1 405 Method Not Allowed
Allow: GET, HEAD, OPTIONSWhy you might see it unexpectedly
- A frontend calling the wrong verb after an API change.
- A CORS preflight rejected because the route does not handle OPTIONS.
- A load balancer or framework rewriting the method.
- Confusing a collection endpoint with an item endpoint.
Related status codes
404 Not Found is a missing path. 501 Not Implemented is an unsupported method globally. 204 No Content is a successful DELETE. 200 OK is a successful GET.