What HTTP 405 means
For example, sending POST to an endpoint that only accepts GET. The response must include an Allow header listing the supported methods. If the method isn’t implemented anywhere on the server, 501 is the right code instead.
How to fix a 405 error
- A missing or extra trailing slash can route a POST to a different handler, or a redirect can turn it into a GET.
- Static hosts and CDNs often return 405 for POST to a static file, e.g. a form posting to an HTML page.
- Check CORS: a failing OPTIONS preflight sometimes shows up as 405.
Retrying
No. Fix the request first; sending it again unchanged will get the same response.
Example response
HTTP/1.1 405 Method Not Allowed
Date: Wed, 21 Oct 2026 10:30:00 GMT
Allow: GET, HEAD
Content-Type: application/json
How to return 405
res.status(405).json({ error: 'Method Not Allowed' });
from fastapi import HTTPException
raise HTTPException(status_code=405, detail="Method Not Allowed")
http.Error(w, http.StatusText(http.StatusMethodNotAllowed), http.StatusMethodNotAllowed)
location /private/ {
return 405;
}
Related status codes
- 501 Not Implemented : The server doesn’t support the functionality needed for the request.
- 404 Not Found : The server can’t find the requested resource.
- 400 Bad Request : The server can’t process the request because it is malformed.
Other 4xx status codes
400 Bad Request · 401 Unauthorized · 402 Payment Required · 403 Forbidden · 404 Not Found · 406 Not Acceptable · 407 Proxy Authentication Required · 408 Request Timeout · 409 Conflict · 410 Gone · 411 Length Required · 412 Precondition Failed · 413 Content Too Large · 414 URI Too Long · 415 Unsupported Media Type · 416 Range Not Satisfiable · 417 Expectation Failed · 418 I’m a Teapot · 421 Misdirected Request · 422 Unprocessable Content · 423 Locked · 424 Failed Dependency · 425 Too Early · 426 Upgrade Required · 428 Precondition Required · 429 Too Many Requests · 431 Request Header Fields Too Large · 444 No Response · 451 Unavailable For Legal Reasons · 499 Client Closed Request
See the full list of HTTP status codes.
Sources
Spotted a mistake? Email hello@devtoolsmith.com and we’ll fix it.
Frequently asked questions
What does HTTP 405 Method Not Allowed mean?
HTTP 405 Method Not Allowed means the resource exists but doesn’t support the HTTP method used. For example, sending POST to an endpoint that only accepts GET. The response must include an Allow header listing the supported methods. If the method isn’t implemented anywhere on the server, 501 is the right code instead.
How do I fix HTTP 405?
A missing or extra trailing slash can route a POST to a different handler, or a redirect can turn it into a GET. Static hosts and CDNs often return 405 for POST to a static file, e.g. a form posting to an HTML page. Check CORS: a failing OPTIONS preflight sometimes shows up as 405.