Method Not Allowed
Client Error (4xx)The 405 Method Not Allowed status code indicates that the HTTP method used in the request is not supported for the target resource. The server must include an Allow header listing the methods that are supported. For example, a resource that only supports GET and HEAD would return 405 for a POST request.
What is HTTP 405 Method Not Allowed?
HTTP 405 Method Not Allowed is a client error (4xx) status code. The 405 Method Not Allowed status code indicates that the HTTP method used in the request is not supported for the target resource. The server must include an Allow header listing the methods that are supported. For example, a resource that only supports GET and HEAD would return 405 for a POST request. Common causes include sending post to a get-only endpoint and trying to delete a read-only resource. To fix it, check the allow header in the response for supported methods.
Example Response
HTTP/1.1 405 Method Not Allowed Allow: GET, HEAD, OPTIONS
Common Causes
- • Sending POST to a GET-only endpoint
- • Trying to DELETE a read-only resource
- • Incorrect method in API client configuration
- • Missing method handler in the server route
How to Fix
- 1. Check the Allow header in the response for supported methods
- 2. Verify your client is using the correct HTTP method
- 3. Review API documentation for the endpoint's allowed methods
- 4. Add the missing method handler to your server route
Frequently Asked Questions
How do I find which methods are allowed?
Check the Allow header in the 405 response. It lists all HTTP methods the resource supports. You can also send an OPTIONS request, which many servers respond to with the same Allow header.
Why am I getting 405 for POST but GET works?
The endpoint exists but does not have a POST handler. This commonly happens when trying to submit data to a read-only endpoint. Check the API documentation or the Allow header for supported methods.
Can 405 occur with CORS preflight requests?
Yes. If the server does not handle OPTIONS requests (used for CORS preflight), it may return 405. Ensure your server responds to OPTIONS with appropriate CORS headers.