Both HTTP 405 and HTTP 501 relate to unsupported HTTP methods, but they differ in scope and protocol responsibility.

Route-specific vs. Global capability

  • HTTP 405 Method Not Allowed (4xx): The server knows the HTTP verb (e.g., POST), but the target route only allows GET and HEAD. The server must send an Allow header listing supported verbs.
  • HTTP 501 Not Implemented (5xx): The server does not support or recognize the method anywhere across any route on the server (e.g., custom verbs like PURGE or WebDAV PROPFIND).

How to test with curl

curl -i -X POST https://api.example.test/v1/read-only-route

Key takeaway

Return 405 Method Not Allowed when a specific URL route forbids a standard HTTP method. Return 501 Not Implemented when the server software lacks the underlying capability to process the method globally.