HTTP 405

405 Method Not Allowed

Client Error

The request method is known by the server but is not supported by the target resource. For example, a client attempts POST on an endpoint that only accepts GET, or DELETE on a read-only resource. The response must include an Allow header listing the methods the resource does support. Clients and tooling rely on this header to discover the correct method without trial and error.

When does this happen?

Return 405 when the URL matches a route but the route does not handle the method the client used. Common cases include API endpoints that only accept POST being hit with GET (e.g., a search-by-body endpoint), CDN-cached pages where the CDN only permits GET and HEAD, and read-only assets where the client mistakenly issued DELETE. Web servers like Nginx and Apache return 405 for static files that are accessed via a method other than GET or HEAD. Browsers will not display anything special for a 405. The client must handle it in code. The Allow header is mandatory by spec, although in practice some frameworks omit it; if you control the server, make sure your handler emits Allow with the correct list of methods. Be wary of CORS preflight: if your OPTIONS handler returns 405 because you forgot to enable OPTIONS on the route, every cross-origin request will fail in browsers.

Common causes

How to fix it

Real-world examples

API client calls DELETE /v1/orders/{id} on an audit-log API where orders are immutable.
Server returns 405 with Allow: GET, POST and body {"error":"method_not_allowed"}. Client switches to a void or cancel endpoint instead.
Single-page app makes a cross-origin POST to api.example.com but OPTIONS is not registered on the route.
Browser preflight gets 405. The real POST is never sent. Console shows a CORS error and the developer adds an OPTIONS handler.
Developer types curl https://example.com/upload (which defaults to GET) on an upload endpoint that only accepts POST.
Server returns 405 with Allow: POST. Developer reruns with -X POST and includes the file body.
CDN-fronted static asset path is requested with PUT by a tool attempting to deploy via the wrong API.
CDN returns 405 with Allow: GET, HEAD. The deploy tool falls back to the correct upload endpoint.
API documentation says PATCH for partial updates but the framework only registered PUT.
Server returns 405 with Allow: PUT. Client switches to PUT with a full resource body until the API is fixed.

Debugging

How it differs from related codes

HTTP 400

400 is for malformed requests at the syntax level. 405 is specifically about the method being wrong for an otherwise-valid URL.

HTTP 404

404 means the URL is unknown. 405 means the URL is known but the method does not apply. If you get 405, the route exists.

HTTP 501

501 means the server does not implement the method at all (e.g., the server does not understand PATCH globally). 405 is per-resource. Other URLs may support the same method fine.

Related status codes

400 401 403 404 415 422

See HTTP 405 in your redirect chains?

Check your URLs with checkredirects.io