406 Not Acceptable

No representation matches the Accept header.

When to use it

The client asked for XML from a JSON-only API.

Common causes and fixes

406 appears when the server takes the Accept header strictly: the client asks for application/xml or a narrow vendor type, and the server can only produce something else. Some frameworks, such as Rails respond_to blocks and Spring endpoints with produces, return 406 instead of falling back. Send Accept: application/json, or omit the header, and check what your HTTP client sends by default.

On shared hosting, ModSecurity and similar web application firewalls have long answered blocked requests with 406, which looks like a content negotiation problem but is really a security rule; check the WAF log or ask the host. When designing an API, the spec lets you ignore an unsupported Accept and return your default format, which is usually friendlier than 406.

Client error (4xx)

4xx codes are client errors: the request itself is wrong, unauthorised or points at something that isn’t there. Retrying the same request won’t help.

What it looks like

HTTP/1.1 406 Not Acceptable

How to send it

Node.js / Expressres.status(406).end()
Python / Flaskreturn '', 406
nginxreturn 406;

How to check it

curl -s -o /dev/null -w "%{http_code}\n" https://example.com/

Open HTTP Status Codes