Software

405 Method Not Allowed With API Examples

405 Method Not Allowed means the URL exists but rejects that HTTP method. Read the Allow header, fix the request, and try methods against a sample API.

405 Method Not Allowed means the server knows the URL, but the resource does not support the HTTP method you used, for example PATCH where only PUT is accepted, or POST to a read-only page. The response must include an Allow header listing the methods that do work. Change the method (or the URL) to one of those.

A real 405

Our test API lets you read, replace and delete an order, but not patch it:

$ curl -i -X PATCH http://127.0.0.1:9201/api/orders/42
HTTP/1.1 405 Method Not Allowed
content-type: application/json
allow: GET, HEAD, PUT, DELETE

{"error":"method_not_allowed","allowed":["GET","HEAD","PUT","DELETE"]}

The allow header is the answer: send PUT with the full order instead. Try other combinations against the same two routes:

Try itPick a method and path to see what the sample API answers.

405 Method Not Allowed

HTTP/1.1 405 Method Not Allowed
Allow: GET, HEAD, PUT, DELETE
Content-Type: application/json

{"error":"method_not_allowed","allowed":["GET","HEAD","PUT","DELETE"]}

Fix: send one of GET, HEAD, PUT, DELETE, or call the URL that supports PATCH.

Common causes

  • The wrong verb for the API design. Collections (/orders) usually accept GET and POST; individual items (/orders/42) accept GET, PUT, PATCH or DELETE. Creating with PUT on a collection, or POST to an item, often returns 405.
  • A form or JavaScript sending POST to a static page. Static hosting serves files with GET; a POST to /contact.html gets 405 from the web server.
  • A trailing-slash or redirect change. Many clients turn POST into GET when following a 301 or 302. If the redirect target only accepts POST, you may see 405 on the second request. Use the final URL directly, or a 307/308 redirect, which keeps the method.
  • CORS preflight. Browsers send OPTIONS before some cross-origin requests. A server that does not handle OPTIONS answers 405 and the browser blocks the real request.
  • A security rule. Web application firewalls and server configs sometimes block methods such as PUT and DELETE globally.

405 vs neighbours

CodeMeaning
404 Not Foundthe URL itself does not exist
405 Method Not AllowedURL exists, method not supported for it
501 Not Implementedthe server does not support that method for any resource
400 Bad Requestmethod is fine; the request content is not

Find the allowed methods

Read the Allow header on the 405 response, or ask directly with OPTIONS if the server supports it: curl -i -X OPTIONS https://api.example.test/orders/42. The API reference should list the methods per endpoint too.

For API developers

Always send Allow with a 405, as RFC 9110 requires; return 405 rather than 404 when the resource exists, so clients can tell the difference; and handle OPTIONS if browsers will call your API cross-origin. If the request content is the problem rather than the method, the right status is 400; see the 400 Bad Request guide.

Sources

  1. RFC 9110: HTTP Semantics, 405 and the Allow header — IETF
  2. 405 Method Not Allowed — MDN

How we made this

Reproduced in a local lab. We sent PATCH to a resource on a local Node.js test API that supports GET, HEAD, PUT and DELETE, and recorded the response with curl -i. The interactive example models the same two routes.

Performed by Claude, an AI assistant working in the BinConvert repository (macOS, Node.js 25.8.2, curl 8.7.1), November 16, 2026.

This article was drafted with AI assistance. Every example, calculation and command output on this page was re-run or checked before release; the PATCH request was re-sent and the response compared. Review: automated test suite and source check, November 16, 2026.

Spotted an error? Tell us and we will correct it.

Copied to clipboard!