501 Not Implemented
Server Error - Functionality not supported
HTTP 501 Not Implemented
What It Means
The HTTP 501 Not Implemented status code indicates that the server does not support the functionality required to fulfill the request. This is typically used when the server doesn't recognize the request method at all.
501 vs 405
- 405: "I know this method, but it's not allowed on this resource"
- 501: "I don't support this method at all on any resource"
When to Use 501
- Unrecognized HTTP methods: Custom method server doesn't handle
- WebDAV methods: PROPFIND, MKCOL, COPY, MOVE on non-WebDAV server
- Future HTTP methods: New methods not yet implemented
- Proxy limitations: Proxy can't handle certain methods
Example Response
PROPFIND /resource HTTP/1.1
Host: example.com
---
HTTP/1.1 501 Not Implemented
Content-Type: application/json
{
"error": "Not Implemented",
"message": "The PROPFIND method is not supported"
}
Comparison Table
| Scenario | Status |
|---|---|
| DELETE on /users/:id (not allowed) | 405 |
| PROPFIND on any endpoint | 501 |
| Custom "PURGE" method | 501 |
| PUT on read-only endpoint | 405 |
Implementation
Express.js
const supportedMethods = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'];
app.use((req, res, next) => {
if (!supportedMethods.includes(req.method)) {
return res.status(501).json({
error: 'Not Implemented',
message: `The ${req.method} method is not supported`
});
}
next();
});
Nginx
# Nginx returns 501 for methods it doesn't understand by default
# For custom handling:
if ($request_method !~ ^(GET|POST|PUT|DELETE|OPTIONS)$ ) {
return 501;
}
Common HTTP Methods
Standard Methods (should NOT return 501):
GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS
WebDAV Methods (may return 501):
PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK
Best Practices
- Most REST APIs should handle standard HTTP methods (use 405, not 501)
- Return 501 for truly unsupported methods like WebDAV
- Include a clear message about what is not supported
- Consider if you actually mean 405 instead