What does HTTP 405 mean?
The URL exists, but does not support the HTTP method used. For example, sending POST to an endpoint that only accepts GET. The response must include an Allow header listing the supported methods.
4xx Client error: The request has a problem the client can fix: wrong URL, missing credentials, bad data or too many requests.
Common causes of a 405 error
- A form or API client using the wrong method.
- A static host that does not accept
POSTto HTML files. - A CORS preflight
OPTIONSrequest that the server does not handle.
How to fix 405 Method Not Allowed
- Check the method in the API documentation and the
Allowheader. - Add an
OPTIONShandler (or CORS middleware) for cross-origin APIs.
405 and SEO
Crawlers use GET; a page returning 405 to GET will not be indexed.
Example response
HTTP/1.1 405 Method Not Allowed
Allow: GET, HEAD
How to return a 405 response
Node.js (Express)
res.status(405).json({ error: 'Method Not Allowed' });PHP
http_response_code(405);Python (Flask)
return {'error': 'Method Not Allowed'}, 405Go (net/http)
w.WriteHeader(405)nginx
return 405;
Related status codes
- 400 Bad Request — The server cannot process the request because it is malformed.
- 404 Not Found — The server cannot find anything at the requested URL.
- 501 Not Implemented — The server does not support the functionality required to fulfil the request.
Check which status code a URL returns with the HTTP header checker.
Часто задаваемые вопросы
What does status code 405 mean?
How do I fix a 405 error?
Allow header. Add an OPTIONS handler (or CORS middleware) for cross-origin APIs.