405Method Not Allowed
The address exists, but it does not accept this method. The Allow header lists the ones it does.
How you get a 405
A DELETE arrives at an address that only supports reading. The app's router knows the address, sees the method is not on its list, and the app sends 405 with an Allow header.
Who sends itApp · Proxy
- Browser
- CDN
- Proxy
- App
- DB
Typically the app, whose router knows which methods each address accepts. A proxy sends it when a request such as POST hits something it serves by itself, like a static file.
In short
What a 405 Method Not Allowed means
A 405 Method Not Allowed means the address is fine and the verb is not: you sent a DELETE to something that can only be read, or a POST to something that only accepts GET. The response must include an Allow header listing the methods that are accepted, which usually makes the fix obvious. The application typically sends it, because its router knows which methods each address supports. A proxy can send it too: nginx answers 405 when a POST is aimed at a static file it serves directly. A common indirect cause is a redirect. A POST that passes through a 301 or 302 is usually re-sent as a GET, and if the target only accepts POST, the 405 appears one hop after the real mistake.
Common causes of a 405
1The client uses the wrong method for this endpoint.
How to check: Read the Allow header on the response.
curl -si -X DELETE https://api.example.com/items | grep -i allow2A redirect turned a POST into a GET, and the target only accepts POST.
How to check: Follow the request and look for a 301 or 302 before the 405. Call the final address directly.
curl -siL -X POST https://example.com/api/items -d '{}' | grep -iE '^HTTP|location'3A POST reached a static file or a path the proxy serves by itself.
How to check: The error page is nginx's. Check that the API path is routed to the app.
405 Not Allowed4The route for this method exists in code but was not registered or deployed.
How to check: List the registered routes in the running app and compare with the one you call.
Retry or not?
Retry only after fixing the request
Headers that matter
- Allow
- Required on a 405. Lists the methods this address accepts, such as GET, HEAD.
In the real world
RFC vs real deployments
RFC 9110 requires the Allow header on a 405, and separates it from 501, which is for methods the server does not implement anywhere. In practice Allow is often missing, and some frameworks answer 404 for a known address with the wrong method. The redirect case causes the most confusion, because the request the server saw is not the request the client meant to send.
Seen in a real outage
Refusing an operation that should not be possible is a safety feature. In 2017 a mistyped command removed far more of Amazon S3's capacity than intended, because the tool accepted it. AWS changed the tool to refuse afterwards.
Your turn
Which code is it?
A client POSTs to http://api.example.com/orders and gets 405 with “Allow: POST”. The endpoint clearly accepts POST. What happened?
405 questions
- Who sends a 405 Method Not Allowed?
- Typically the application, whose router knows which methods each address accepts. A proxy sends it when a method such as POST is aimed at something it serves by itself.
- How do I fix a 405?
- Read the Allow header in the response: it lists the methods that work. Then check that no redirect changed your method on the way.
- What is the difference between 404 and 405?
- A 404 says nothing is at that address. A 405 says the address exists but does not accept the method you used.
Sources: RFC 9110: 405 Method Not Allowed (section 15.5.6) ↗ · RFC 9110: Allow (section 10.2.1) ↗ · Report a problem
Diagrams are our own simulations. All wording is original and paraphrases the linked sources.
Practise this in the DNS / HTTP track
Two-minute animated lessons, then boss fights from real outages. Free, no account needed.