HTTP
HTTP 405Method Not Allowed
HTTP 405 Method Not Allowed means the URL exists but the server does not accept the HTTP method used, such as a POST sent to a static HTML file or a DELETE to an endpoint that only handles GET. The response must include an Allow header listing the methods the resource supports.
What 405 means
The server found the resource but the method (GET, POST, PUT, DELETE, PATCH, OPTIONS…) is not one it supports there. It differs from 404 (nothing at that URL) and from 501 Not Implemented (the server does not understand the method at all).
Common causes
- Static files: web servers serve files with GET and HEAD only. A form or script that POSTs to
/contact.htmlreceives 405 (Apache) or a 405/403 depending on server. - Framework routing: the route exists for GET but the client sent POST, or vice versa. Express, Django, Rails, Laravel and ASP.NET all return 405 (or 404, depending on configuration) for method mismatches.
- API gateways and CDNs: rules that only pass certain methods.
- WebDAV or IIS handler mappings that exclude the method.
- CORS preflight: an OPTIONS request reaches an application that does not handle OPTIONS.
Fixing
- Read the
Allowheader in the response. - Check the client: is the method what you intended? Redirects can change POST to GET (301, 302).
- Check the route definition or handler mapping on the server.
- For static hosting, move the handler to a real endpoint or a form service.
curl -i -X POST https://example.com/contact.html
curl -i -X OPTIONS https://example.com/api/itemsFrequently asked questions
Why do I get 405 when submitting a form?
The form's action points to a static page (an .html file) or to a route registered only for GET. Point the action at the handler URL and make sure the server route accepts POST.
How do I see which methods are allowed?
curl -i -X OPTIONS https://example.com/path or the Allow header in the 405 response itself.