4xx Client Errors
HTTP 405 Method Not Allowed
The request HTTP method is not allowed for the target resource.
When is 405 used?
- POST on a read-only endpoint
- DELETE on a protected resource
How to handle a 405 response
Inspect the request — URL, method, headers, credentials, and body. Retrying the same request unchanged will usually fail again; 429 is the exception, where you should wait for the Retry-After period.
Check the status code a URL returns from the command line:
curl -s -o /dev/null -w "%{http_code}\n" https://example.comHow to return 405 from your server
Node.js (Express)
res.status(405).json({ message: 'Method Not Allowed' });Python (Flask)
return {"message": "Method Not Allowed"}, 405Go (net/http)
w.WriteHeader(405)Frequently Asked Questions
What does HTTP 405 mean?
405 Method Not Allowed: The request HTTP method is not allowed for the target resource.
Is 405 an error?
Yes. 405 is in the 4xx Client Errors class. Client errors: the request is malformed, unauthorized, or targets something that does not exist.