What 405 means
The URL exists but doesn’t support the request method, such as a POST to a page that only takes GET. The server must say which methods it does allow in an Allow header.
When servers send it
When a route exists for some methods but not the one used.
Common causes
- Posting a form to a static file or a GET-only route.
- Calling an API with PUT when it expects PATCH (or the other way round).
- A redirect turning a POST into a GET (see 301 and 302).
- A static host that doesn’t run server code, so POST isn’t allowed at all.
- The CORS preflight (OPTIONS) not being handled.
How to fix it as a developer
- Read the
Allowheader to see which methods work. - Check the route is registered for this method, and that the URL is exactly right (a trailing slash can send you to a different route).
- If a redirect sits in front, use 307 or 308 so the method is kept.
- Handle OPTIONS for CORS preflight requests, usually with 204.
How to fix it as a visitor
- Go back and try again from the site’s own link or form. If it keeps happening, the site has a bug; let them know.
Related codes
- 404 Not Found: There’s nothing at this URL, or the server won’t say whether there is.
- 501 Not Implemented: The server doesn’t support the feature needed to answer, such as an unknown request method.
- 400 Bad Request: The server can’t or won’t handle the request because something in it is malformed.
- 308 Permanent Redirect: The page has moved for good. Repeat the same request at the new URL, with the same method and body.
Where it’s defined
405 Method Not Allowed is defined in RFC 9110, section 15.5.6. It’s a 4xx code, the client error class: something is wrong with the request, so sending it again unchanged won’t help.
Other 4xx codes
400 Bad Request · 401 Unauthorized · 402 Payment Required · 403 Forbidden · 404 Not Found · 406 Not Acceptable · 408 Request Timeout · 409 Conflict · 410 Gone · 413 Content Too Large · 414 URI Too Long · 415 Unsupported Media Type · 418 I’m a teapot · 422 Unprocessable Content · 429 Too Many Requests · 431 Request Header Fields Too Large · 451 Unavailable For Legal Reasons · 499 Client Closed Request
Or search them all in the HTTP status code list.
Questions people ask
What does HTTP 405 Method Not Allowed mean?
What’s the difference between 405 and 501?
Does a 405 have to include an Allow header?
Allow header listing the methods the resource supports.