Troubleshooting guide
405 Method Not Allowed: why it happens and how to fix it
A 405 means the URL exists, but it does not accept the HTTP method you used. Usually a POST or PUT reached something that only serves GET.
4 min read10 sectionsUpdated
On this page
Common causes
- The request reached the wrong backend. Nginx serving static files rejects POST with 405, which usually means
locationmatching did not send the request to your application. - A redirect changed the method. A 301 or 302, often from HTTP to HTTPS or for a trailing slash, leads many clients to retry with GET. The server then rejects a GET on a POST-only route.
- A missing route handler. The application defines GET for a path and the client sends PUT.
- CORS preflight. The browser sends OPTIONS first, and the server does not handle it.
- A security rule on IIS or a WAF that disables PUT and DELETE.
Diagnose it
Ask the server what it allows, then send the actual method without following redirects, so you can see any hidden 30x.
# Which methods does this URL allow?
curl -si -X OPTIONS https://api.example.com/items | grep -iE '^(HTTP|allow|access-control)'
# Send the real method and do NOT follow redirects
curl -si -X POST https://api.example.com/items -d '{}' | head -12
# Does a slash change the answer?
curl -s -o /dev/null -w "%{http_code} %{redirect_url}\n" -X POST https://api.example.com/items/Fixes
If a redirect is involved, call the final URL directly, and use 307 or 308 on the server, because those status codes require clients to keep the method. If Nginx is answering, fix the location block so requests reach proxy_pass. For CORS, handle OPTIONS at the proxy or framework level and return the allowed methods and headers. If a route is missing, confirm that the deployed version of the code actually includes it.
Catch it automatically
A 405 after a release usually means a client and server were deployed out of step. A multi-step API check that sends the real method and asserts the status catches this where a GET-only check never would. In APM, a route that moves suddenly from 2xx to 405 is a clear deployment marker.
What is the difference between 404 and 405?
404 means nothing exists at that URL. 405 means something exists but it does not support the HTTP method used.
Why is my POST turning into a GET?
A 301 or 302 redirect makes many clients repeat the request with GET. Call the final URL directly, or use 307 or 308 redirects, which preserve the method.
Why do I get 405 on OPTIONS?
That is a CORS preflight the server does not handle. Add OPTIONS handling that returns the allowed origins, methods and headers.
Check it now, free
- Website down checker: Is it down for everyone or just me? Check any site now.
Related reading
- 501 Not Implemented: how to fix it: Fix 501 Not Implemented: unsupported HTTP methods, servers and proxies that do not support PATCH or WebDAV, and how it differs from 405 and 500.
- 400 Bad Request: what it means and how to fix it: Fix a 400 Bad Request error: oversized cookies, malformed URLs, invalid JSON bodies and proxy rules, with commands to find which layer rejected it.
- 422 Unprocessable Entity: how to fix it: Fix 422 Unprocessable Entity (Unprocessable Content): validation errors in APIs and forms, CSRF tokens in Rails and Laravel, and how to read the error body.
- 408 Request Timeout: causes and how to fix it: Understand 408 Request Timeout: slow client uploads, idle keep-alive connections and proxy settings, and how it differs from a 504 Gateway Timeout.
- 403 Forbidden: what it means and how to fix it: Fix 403 Forbidden errors: file permissions, missing index files, WAF and bot rules, IP allowlists, expired signed URLs and missing API scopes, step by step.
- 404 Not Found: how to find and fix broken pages: Find and fix 404 errors: broken internal links, moved pages, case-sensitive paths and soft 404s, with commands and advice on what actually affects SEO.
Watch your own site and services with VitalRix
Uptime checks, APM, logs, real-user monitoring, alerts and status pages in one place. Every product has a free tier and no credit card is needed.