What 405 Method Not Allowed means
405 Method Not Allowed means the URL exists but does not accept the method you used. Trying to POST to a read-only endpoint, DELETE on a resource that does not support deletion, or PATCH on something that only accepts PUT all yield 405. The response must include an Allow header listing the methods the resource does support, so the client can self-correct without trial-and-error.
When servers should return it: Return 405 when the resource exists but the method is not supported. Always include an Allow header.
Common causes
- Sending POST to a GET-only endpoint
- Sending DELETE to a resource that does not support deletion
- API uses PUT but client sent PATCH (or vice versa)
- Method not implemented yet on the server side
How to fix 405 Method Not Allowed
- Read the Allow response header to see what methods are supported
- Check the API documentation
- Verify the curl -X flag matches the documented method
- For frameworks that auto-generate routes, confirm the route definition includes the method you need
Example response
curl -i -X DELETE https://api.example.com/health
HTTP/2 405
allow: GET, HEAD
content-type: application/json
{"error":"method not allowed"}
More references
For a one-page reference of all HTTP status codes, see the HTTP cheat sheet. For testing API responses, try the API Tester tool. For inspecting responses on the command line, the curl cheat sheet covers the most common flags.