HTTP 406 Not Acceptable — What It Means & How to Fix
HTTP 406 Not Acceptable means the server cannot produce a response matching the Accept headers sent by the client — content negotiation failure.
What It Means
The HTTP 406 Not Acceptable status code is the result of failed content negotiation. When a client sends a request with an Accept header specifying which media types, languages, or character sets it can handle, the server checks if it can produce a response matching those preferences. If none of the available representations match, the server returns 406.
Content negotiation is the process where the client and server agree on the best representation of a resource. The client communicates its preferences through headers like:
Accept— which MIME types are acceptable (e.g.,application/json,text/html,image/webp)Accept-Language— preferred languages (e.g.,en-US,fr-FR)Accept-Charset— character encodings (e.g.,utf-8)Accept-Encoding— compression algorithms (e.g.,gzip,br)
A 406 response may optionally include a list of available representations in the body so the client can choose an alternative. In practice, many servers return 406 with an error message describing which formats are supported.
When It’s Sent
- Wrong Accept header — a client sends
Accept: application/xmlbut the API only supports JSON - Missing language variant — a client requests
Accept-Language: es-MXbut the site only hasenandfr - API version mismatch — a client specifies an unsupported content type for a specific endpoint version
- Static file negotiation — a server offers a file in multiple formats but the requested format is unavailable
- Custom media type error — a client sends
Accept: application/vnd.api+jsonbut the server doesn’t recognize it
Real Example
curl -v -H "Accept: application/xml" https://api.example.com/users/1Expected response:
> GET /users/1 HTTP/1.1
> Host: api.example.com
> Accept: application/xml
>
< HTTP/1.1 406 Not Acceptable
< Content-Type: application/json
< Content-Length: 103
<
{"error":"not_acceptable","message":"This API only supports application/json","available_types":["application/json"]}The server clearly states that only application/json is available. The client can retry with the correct Accept header.
How to Debug
Client-Side
- Check the Accept header — verify you are sending the correct MIME type for the endpoint
- Review API documentation — confirm which content types the endpoint supports
- Remove restrictive Accept headers — try without
Acceptor useAccept: */*to see the default response - Check Accept-Language — if the server doesn’t support your language, try
Accept-Language: * - Inspect the response body — many APIs list the supported formats in the error response
Server-Side
- Review content negotiation logic — check how your framework resolves
Acceptheaders - Verify registered renderers — in frameworks like Rails or Django REST, ensure the correct renderers are configured
- Check the supported formats list — make sure the endpoint advertises its available formats
- Test with no Accept header — the server should have a default format it returns
- Review middleware — some middleware may override or strip content negotiation headers
curl
# Request a specific format
curl -s -w "\nHTTP: %{http_code}\n" \
-H "Accept: text/csv" https://api.example.com/report
# Check what formats the server offers (use OPTIONS or no Accept header)
curl -s -D - https://api.example.com/report | head -20Postman
Set the Accept header in the Headers tab. Try with Accept: application/json and Accept: text/csv to compare responses. The status badge changes between 200 and 406 depending on supported formats.
Common Causes
| Scenario | What Happens | Why It Matters |
|---|---|---|
| Wrong media type | Client requests XML, server only serves JSON | Update the client’s Accept header |
| Missing language variant | Client requests Spanish, server only has English | Add language support or return a fallback |
| Unsupported API version | Client uses application/vnd.api.v2+json but server only has v1 | Check API versioning documentation |
| Custom content type | Client uses a vendor-specific MIME type the server doesn’t recognize | Use standard MIME types or register the custom type |
| Framework misconfiguration | Django/Rails/Express isn’t configured to render the requested format | Add the appropriate renderer or serializer |
FAQ
Related Codes
- HTTP 200 OK — successful response with the correctly negotiated format
- HTTP 415 Unsupported Media Type — server cannot process the request’s Content-Type
- HTTP 404 Not Found — resource does not exist regardless of format
- HTTP 500 Internal Server Error — server error during content negotiation
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro