Qaynaq LABS · TOOLS

HTTP · 4xx Client Error

406 Not Acceptable

Server cannot produce a response matching client's requested Accept headers.

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

  1. Inspect client's Accept header in request
  2. Verify server's supported content types
  3. Check server logs for content negotiation failures
  4. 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.

Frequently asked

How do I handle 406 in a browser?

Browsers typically send Accept: */* so 406 rarely occurs. Implement server-side fallback content.

Can I return 406 with a response body?

Yes, though clients may ignore it. Include details about supported content types in the body.

Is 406 cacheable?

No. Responses with 406 must not be stored by caches per RFC 7231.