4064xx
4xx — Client Error
Not Acceptable
The server cannot produce a response matching the list of acceptable values defined in the request's proactive content negotiation headers.
What it means
The HTTP 406 Not Acceptable client error response code indicates that the server cannot produce a response matching the list of acceptable values defined in the request's proactive content negotiation headers (like `Accept`, `Accept-Language`, or `Accept-Encoding`).
How it works
- 1The client requests an endpoint and says 'Accept: application/xml'.
- 2The server only knows how to generate 'application/json'.
- 3The server returns 406 to tell the client 'I can't give you what you asked for'.
Why you're seeing this
- • The client provided an Accept header that the server cannot fulfill.
How to fix it
- • Change the Accept header in the request to match what the server actually provides (usually */* or application/json).
Framework Implementations
Express.js
app.get('/data', (req, res) => {
if (!req.accepts('json')) return res.status(406).send('Not Acceptable');
res.json({ success: true });
});Real-Life Scenarios
Use this in strictly designed REST APIs that enforce Content Negotiation, though in practice, many APIs simply ignore the Accept header and return JSON (with a 200).
Strict Content Negotiation
A legacy client requests XML from a modern API that only speaks JSON. The API strictly returns 406 to force the client to update their Accept headers.
HTTP Transaction
1. Client Request
GET /data HTTP/1.1 Accept: application/xml
2. Server Response
HTTP/1.1 406 Not Acceptable
Content-Type: application/json
{"error": "Only application/json is supported"}SEO Implications
None.