This URL doesn’t support that HTTP method.
When to use it
A POST to a read-only endpoint. Include an Allow header.
Common causes and fixes
Typical causes: a POST to a route only defined for GET, a framework route missing its PUT or DELETE handler, a form posting to a static file (nginx answers 405 to POST on static content), or a trailing slash redirect that turned a POST into a GET. The response should include an Allow header listing the supported methods; check it with curl -i -X OPTIONS against the URL.
A CORS preflight that hits a route without an OPTIONS handler gets 405, and the browser reports it as a CORS error instead. Add CORS middleware that answers OPTIONS before routing. Static hosts such as S3 website endpoints and GitHub Pages don’t accept POST at all, so forms there need a separate backend. Use 501 when the server doesn’t recognise the method anywhere.
Client error (4xx)
4xx codes are client errors: the request itself is wrong, unauthorised or points at something that isn’t there. Retrying the same request won’t help.
What it looks like
HTTP/1.1 405 Method Not AllowedHow to send it
| Node.js / Express | res.status(405).end() |
|---|---|
| Python / Flask | return '', 405 |
| nginx | return 405; |
How to check it
curl -s -o /dev/null -w "%{http_code}\n" https://example.com/