More
More
406 Not Acceptable
The server cannot produce a response in any format the client's Accept headers allow.
- Code
406- Reason phrase
- Not Acceptable
- Class
- 4xx Client error
- Defined in
- RFC 9110 section 15.5.7
- Cacheable by default
- No
What it means
Client error: the problem lies with the request. Repeating it unchanged will normally fail again.
When a server should send it. When the client's Accept, Accept-Language or Accept-Encoding headers rule out every format the server has. Most servers sensibly ignore that and send their default format instead, which the standard allows.
Common causes. An API client asking for XML from a JSON only API, or a security module reacting to unusual headers.
What to do. Loosen the Accept header, for example to */*.
How clients and crawlers treat it
Browsers and HTTP clients. Rarely seen by browsers because they send broad Accept headers. Some web application firewalls return it to block requests, which is a misuse.
Google Search. Like every 4xx except 429, it tells Google the content does not exist: an indexed URL is removed from the index, and a new one is not processed. Crawl frequency for the URL gradually drops. Source: Google Search Central, How HTTP status codes, and network and DNS errors affect Google Search.
Caching. Not cacheable by default (RFC 9110 section 15.1 does not list it). A cache stores it only when the response says so with Cache-Control or Expires.
Example response
HTTP/1.1 406 Not Acceptable Content-Type: text/plain; charset=utf-8 Not Acceptable
How to send 406
location /example {
return 406;
}
RewriteEngine On RewriteRule ^example$ - [R=406,L]
http_response_code(406); echo 'Not Acceptable'; exit;
res.writeHead(406, { 'Content-Type': 'text/plain' });
res.end('Not Acceptable');
# in a view function return 'Not Acceptable', 406
Change the paths to suit. In nginx, add_header needs always to apply to error responses.
Related codes
- 415Unsupported Media TypeThe server does not accept the format of the request body.
- 400Bad RequestThe server could not understand the request.
- 300Multiple ChoicesThere are several versions of the resource and the client or user should choose one.
All status codes · All 4xx codes
Names and numbers from the IANA HTTP Status Code Registry. Google Search behaviour as documented by Google Search Central.