devkult_
tools29converters34

405 Method Not Allowed

4xx client error

The URL exists, but it doesn't support the HTTP method used.

405 means the route is right but the verb is wrong — a POST to an endpoint that only accepts GET, or a DELETE the server doesn't implement for that resource. The response must include an Allow header listing the methods the resource does support.

Class4xx Client Error
Retry?No — change the request first
Cacheable by defaultYes (heuristically, per RFC 9110)
Response bodyAllowed
Defined inRFC 9110 §15.5.6 — 405 Method Not Allowed
Example response
HTTP/1.1 405 Method Not Allowed
Allow: GET, HEAD
Content-Type: application/json
Content-Length: 30

{"error":"Method Not Allowed"}

Common causes

  • Sending POST to a static file or a read-only endpoint.
  • A form submitting to a URL whose handler only defines GET.
  • Next.js route handlers: route.ts exports GET but not POST.
  • Static hosts (S3, GitHub Pages, most CDNs) only serve GET and HEAD.

How to fix it

  1. Read the Allow header in the response to see which methods are accepted.
  2. Define a handler for the method on the server, and for OPTIONS if browsers call the endpoint cross-origin.
  3. Point form submissions and API calls at a server endpoint, not a static file.

Useful here: CORS errors explained

Send a 405 from your server

Express
res.set("Allow", "GET, HEAD");
res.status(405).json({ error: "Method Not Allowed" });
Next.js route handler
return Response.json({ error: "Method Not Allowed" }, { status: 405, headers: { "Allow": "GET, HEAD" } });
Flask
return {"error": "Method Not Allowed"}, 405, {"Allow": "GET, HEAD"}
Go net/http
w.Header().Set("Allow", "GET, HEAD")
http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
nginx
add_header Allow "GET, HEAD" always;
return 405;

Check what a URL returns

Print just the status line from the command line, or check a whole list of URLs at once, with their response headers, in the HTTP Status Checker.

curl -sI https://example.com/your-path | head -n 1

Frequently asked questions

405 vs 404?

404: no such resource. 405: the resource exists, but not for this method. Return 405 with an Allow header so clients can correct themselves.

405 vs 501?

405: this resource doesn't support the method. 501: the server doesn't implement the method for any resource.

Headers used with 405
Related status codes