When you see this status
- Client requests JSON but server only supports XML
- Client sends Accept: application/pdf but server renders HTML
- API version requested via Accept header is unsupported
Common causes
- Client sends unsupported Accept header
- Server lacks content negotiation logic
- Misconfigured Accept header parsing
How to debug it
- Inspect client's Accept header in request
- Verify server's supported content types
- Check server logs for content negotiation failures
- Test with curl using -H 'Accept: ...'
Return this code in your framework
Express (Node.js)
res.status(406).send('Not Acceptable');
FastAPI (Python)
from fastapi import status
return JSONResponse(status_code=status.HTTP_406_NOT_ACCEPTABLE)
NestJS
@Get()
getData() {
throw new HttpException('Not Acceptable', HttpStatus.NOT_ACCEPTABLE);
}
Go (net/http)
w.WriteHeader(http.StatusNotAcceptable)
w.Write([]byte("Not Acceptable"))
About HTTP 406
HTTP status code 406 Not Acceptable is part of the
4xx Client Error family. Server cannot produce a response matching client's requested Accept headers. Understanding it is essential for
backend engineers, API designers, and anyone debugging integrations between services.
The Qaynaq Labs HTTP Status Code Explainer covers all standard codes with practical guidance:
what triggers them, how to debug them in production, and exactly how to return them from common
frameworks. Each code page is hand-curated and verified.