Back to all status codes
406

Not Acceptable

The server cannot produce a response matching the list of acceptable values in the request headers.

Common Causes

  • Accept header mismatch
  • Content negotiation failure
  • Unsupported response format

Fix Solutions

Check Accept header

Ensure Accept header includes a format the server can provide.

Code Examples

// Express.js - Content negotiation
app.get('/api/data', (req, res) => {
    const accept = req.headers.accept;
    if (!accept?.includes('application/json')) {
        return res.status(406).json({ 
            error: 'Only JSON format is supported' 
        });
    }
    res.json({ data: [] });
});

Related Tools