Applies to: Apache 2.4.68, Nginx 1.30.5 and the PHP 8.3 built-in server (tested in Docker); RFC 9110 and RFC 9112
HTTP 501 Not Implemented means the server doesn’t support what the request asks for. Most often it means the request method (the word before the URL, such as GET or POST) is one the server doesn’t recognise at all. It is a server-side status code (5xx), but the fix is usually in the client or tool that sent the request.
501 or 405?
RFC 9110 separates the two: a server that gets a method it doesn’t recognise or implement should answer 501; a method it knows but doesn’t allow for that URL gets 405 Method Not Allowed. We sent the same requests to default Apache and Nginx containers:
Method Apache 2.4.68 Nginx 1.30.5 GET 200 200 FOO 501 405 PROPFIND 405 405 PATCH 405 405 DELETE 405 405
So the same mistake gives a 501 on one server and a 405 on another. If you see 405, read 405 Method Not Allowed instead.
What causes a 501
- An unknown or misspelt method. A script, API client or scanner sends something like
FOOorGETT. Apache answers 501 and logsAH00135: Invalid method in request FOO / HTTP/1.1in its error log. - A development server with limited methods. The PHP built-in server (
php -S) answeredFOOwith501 Not Implementedand the text “Request method not supported.” - A Transfer-Encoding the server doesn’t support. RFC 9112 says a server that receives a transfer coding it doesn’t understand should respond with 501. A POST with
Transfer-Encoding: gzipgot a 501 from Nginx (Apache answered that one with 400 Bad Request). - The application says so. Some APIs return 501 on purpose for a feature that isn’t built yet. In PHP,
http_response_code(501);produces exactly that.
How to find and fix it
- Repeat the request with curl and look at the status line and the
Serverheader, which tell you which layer answered:$ curl -i -X FOO http://example.com/ HTTP/1.1 501 Not Implemented Server: Apache/2.4.68 (Unix) Allow: GET,POST,OPTIONS,HEAD,TRACE ... <p>FOO not supported for current URL.<br />
Apache’sAllowheader lists the methods it accepts for that URL. - Check the logs. The access log shows the method and status, for example
"FOO / HTTP/1.1" 501 242. On Apache, look forAH00135in the error log. - Fix the client. Correct the method name in the script, form or API call. Methods are case-sensitive: in our test, a lowercase
getgot a 501 from Apache and a 400 from Nginx. - Check proxies and CDNs. If the site sits behind a proxy, load balancer or CDN, repeat the request against the origin server directly. If only the front layer returns 501, the method or header isn’t supported there.
- If your own code returns 501, find the route or controller that sends it. The status is correct for “not built yet”; if the feature should exist, the route is missing or points to a stub.
Don’t retry the same request in a loop: a 501 will not go away until the method or header changes.
Other status codes: 400 Bad Request, 502 Bad Gateway and 504 Gateway Timeout. If you run Nginx yourself: Nginx configuration basics.
Official documentation: RFC 9110, 501 Not Implemented.