🍽️
406
Not Acceptable
!
?

Example HTTP Response

HTTP Response
HTTP/1.1 406 Not Acceptable
Content-Type: application/json

{"available": ["application/json", "application/xml"]}
Common Causes
  • Accept header doesn't match available formats
  • Language not supported
  • Content negotiation failed
Technical Details

What does this mean?

Picky eater alert! You asked for something in a format the server can't serve. Like ordering sushi at a pizza place.

Technical Definition

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

RFC Says

"The 406 (Not Acceptable) status code indicates that the target resource does not have a current representation that would be acceptable to the user agent, according to the proactive negotiation header fields received in the request, and the server is unwilling to supply a default representation."

Plain English:

The server can't produce a response in any of the formats you requested via Accept headers. For example, if you requested JSON (Accept: application/json) but the server only provides XML, it returns 406.

Common Misinterpretation

Most servers ignore Accept headers or send a default format instead of returning 406. Strict adherence to content negotiation with 406 is rare in practice. Many APIs just return JSON regardless of Accept headers.

Code Snippets

Ready-to-use code for returning this HTTP status in your application:

Node.js
// Express.js
app.get('/example', (req, res) => {
  res.status(406).json({
    error: 'Not Acceptable',
    message: 'Your error message here'
  });
});

// Native HTTP
const http = require('http');

http.createServer((req, res) => {
  res.writeHead(406, { 'Content-Type': 'application/json' });
  res.end(JSON.stringify({
    error: 'Not Acceptable',
    message: 'Your error message here'
  }));
}).listen(3000);