HTTP

501 - Not Implemented

Getting a 501 Not Implemented means the server doesn't support the HTTP method or feature you're requesting—trying PATCH on a server that only supports GET/POST, or requesting HTTP/2 features on an HTTP/1.1-only server. This server-side error (5xx) indicates a permanent limitation, not a temporary issue. Most common when using modern HTTP methods (PATCH, DELETE) on legacy servers, but also appears when requesting unsupported protocol features, WebDAV operations on non-WebDAV servers, or experimental HTTP extensions.

#Common Causes

  • Frontend: Using HTTP methods server doesn't support (PATCH, DELETE, OPTIONS). Requesting HTTP/2 or HTTP/3 features on HTTP/1.1 server. Using WebDAV methods (PROPFIND, PROPPATCH) on regular server. Experimental headers or extensions not supported.
  • Backend: Route handler missing for specific HTTP method. Server framework doesn't support requested method. Feature flag disabled or not implemented. Legacy server without modern method support. Intentionally disabled for security reasons.
  • Infrastructure: Load balancer doesn't forward certain methods. Reverse proxy strips unsupported methods. API gateway method restrictions. Legacy infrastructure without modern HTTP support.

Solutions

  1. 1Step 1: Diagnose - Check DevTools Network tab—verify HTTP method used (GET, POST, PUT, DELETE, PATCH). Review API documentation for supported methods. Check if Allow header lists supported methods.
  2. 2Step 2: Diagnose - Server logs show which method was rejected. Review route definitions for missing method handlers. Check server framework capabilities. Verify infrastructure method filtering.
  3. 3Step 3: Fix - Client-side: Use alternative methods (PUT instead of PATCH, POST with _method override). Check Allow header for supported methods. Fallback to GET/POST if needed. Update client to match server capabilities.
  4. 4Step 4: Fix - Server-side: Implement missing method handlers. Add method support to framework configuration. Return Allow header with supported methods. Upgrade server software if needed.
  5. 5Step 5: Fix - Infrastructure: Configure load balancer to pass all HTTP methods. Review reverse proxy method filtering rules. Update API gateway method mappings. Upgrade infrastructure for modern HTTP support.

</>Code Examples

Fetch API: Fallback for Unsupported Methods
1// Client-side: Handle 501 by checking Allow header and using fallback
2async function updateResource(id, data, usePatch = true) {
3  // Try PATCH first (preferred for partial updates)
4  let response = await fetch(`/api/resources/${id}`, {
5    method: usePatch ? 'PATCH' : 'PUT',
6    headers: { 'Content-Type': 'application/json' },
7    body: JSON.stringify(data),
8  });
9  
10    if (response.status === 501) {
11    // Check Allow header for supported methods
12    const allowedMethods = response.headers.get('Allow');
13    console.warn(`PATCH not supported. Allowed methods: ${allowedMethods}`);
14    
15    if (allowedMethods && allowedMethods.includes('PUT')) {
16      // Fallback to PUT (full resource update)
17      response = await fetch(`/api/resources/${id}`, {
18        method: 'PUT',
19        headers: { 'Content-Type': 'application/json' },
20        body: JSON.stringify(data),
21      });
22    } else if (allowedMethods && allowedMethods.includes('POST')) {
23      // Fallback to POST with _method override
24      response = await fetch(`/api/resources/${id}`, {
25        method: 'POST',
26        headers: {
27          'Content-Type': 'application/json',
28          'X-HTTP-Method-Override': 'PATCH',
29        },
30        body: JSON.stringify(data),
31      });
32    } else {
33      throw new Error(`No supported update method available. Allowed: ${allowedMethods}`);
34    }
35  }
36  
37  return response.json();
38}
39
40// Check server capabilities with OPTIONS
41async function checkServerCapabilities(endpoint) {
42  const response = await fetch(endpoint, { method: 'OPTIONS' });
43  const allowedMethods = response.headers.get('Allow');
44  return allowedMethods ? allowedMethods.split(', ') : [];
45}
Express.js: Implement Missing Methods
1// Server-side: Implement all required HTTP methods
2const express = require('express');
3const methodOverride = require('method-override');
4const app = express();
5
6app.use(express.json());
7app.use(methodOverride('X-HTTP-Method-Override')); // Support _method override
8
9// GET - Read resource
10app.get('/api/resources/:id', async (req, res) => {
11  const resource = await db.resources.findById(req.params.id);
12  if (!resource) {
13    return res.status(404).json({ error: 'Resource not found' });
14  }
15  res.json(resource);
16});
17
18// POST - Create resource
19app.post('/api/resources', async (req, res) => {
20  const resource = await db.resources.create(req.body);
21  res.status(201).json(resource);
22});
23
24// PUT - Full update (replace entire resource)
25app.put('/api/resources/:id', async (req, res) => {
26  const resource = await db.resources.update(req.params.id, req.body);
27  if (!resource) {
28    return res.status(404).json({ error: 'Resource not found' });
29  }
30  res.json(resource);
31});
32
33// PATCH - Partial update (update only provided fields)
34app.patch('/api/resources/:id', async (req, res) => {
35  const resource = await db.resources.partialUpdate(req.params.id, req.body);
36  if (!resource) {
37    return res.status(404).json({ error: 'Resource not found' });
38  }
39  res.json(resource);
40});
41
42// DELETE - Remove resource
43app.delete('/api/resources/:id', async (req, res) => {
44  const deleted = await db.resources.delete(req.params.id);
45  if (!deleted) {
46    return res.status(404).json({ error: 'Resource not found' });
47  }
48  res.status(204).send();
49});
50
51// OPTIONS - Return allowed methods
52app.options('/api/resources/:id', (req, res) => {
53  res.set('Allow', 'GET, POST, PUT, PATCH, DELETE, OPTIONS');
54  res.sendStatus(200);
55});
56
57// Handle unsupported methods
58app.use('/api/resources/:id', (req, res) => {
59  res.status(501)
60    .set('Allow', 'GET, POST, PUT, PATCH, DELETE, OPTIONS')
61    .json({
62      error: 'Not Implemented',
63      message: `Method ${req.method} not supported for this endpoint`,
64      allowed: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'],
65    });
66});
Nginx: Pass All HTTP Methods
1# Nginx: Ensure all HTTP methods reach backend
2server {
3    listen 80;
4    server_name api.example.com;
5    
6    location /api/ {
7        # Pass all HTTP methods to backend
8        proxy_pass http://backend;
9        proxy_set_header Host $host;
10        proxy_set_header X-Real-IP $remote_addr;
11        proxy_set_header X-Forwarded-Method $request_method;
12        
13        # Don't filter methods at Nginx level
14        # Allow all standard methods
15    }
16    
17    # Handle OPTIONS for CORS (if backend doesn't handle it)
18    location /api/ {
19        if ($request_method = OPTIONS) {
20            add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, PATCH, DELETE, OPTIONS';
21            add_header 'Access-Control-Allow-Origin' '*';
22            add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization';
23            return 204;
24        }
25    }
26}

Related Errors

Provider Information

This error code is specific to HTTP services. For more information, refer to the official HTTP documentation.

501 - Not Implemented | HTTP Error Reference | Error Code Reference