HTTP 406 Not Acceptable indicates the server cannot produce a response matching the client's Accept headers (Accept, Accept-Encoding, Accept-Language, Accept-Charset). The server is saying 'I have this resource, but not in any format you'll accept.' This is part of HTTP content negotiation — the client states preferences, and the server tries to match them.
Response includes the status code, standard headers (including Content-Type), and a small diagnostic JSON body describing the request and returned status.
Simulator URL (copy in the app after load — not a normal link):
https://httpstatus.com/api/status/406
Example request:
curl -i "https://httpstatus.com/api/status/406"The requested resource is capable of generating only content not acceptable according to the Accept headers sent in the request.
On this code, Inspector focuses on semantics, headers, and correctness warnings that commonly affect clients and caches.
HTTP 406 Not Acceptable has specific technical implications for API design, caching, and client behavior. Understanding the precise semantics helps distinguish it from similar status codes and implement correct error handling. The response should include a descriptive body following a consistent error schema (like RFC 7807 Problem Details) so clients can programmatically handle the error.
// Handle 406 Not Acceptable in Express
app.use((err, req, res, next) => {
if (err.status === 406) {
return res.status(406).json({
type: 'https://api.example.com/errors/not-acceptable',
title: 'Not Acceptable',
status: 406,
detail: err.message
});
}
next(err);
});from fastapi import HTTPException
# Raise 406 Not Acceptable
raise HTTPException(
status_code=406,
detail={
'type': 'not_acceptable',
'message': 'Descriptive error for 406 Not Acceptable'
}
)// Spring Boot 406 Not Acceptable handling
@ExceptionHandler(CustomNotAcceptableException.class)
public ResponseEntity<ErrorResponse> handleNotAcceptable(
CustomNotAcceptableException ex) {
return ResponseEntity.status(406)
.body(new ErrorResponse("Not Acceptable", ex.getMessage()));
}// Return 406 Not Acceptable
func errorHandler(w http.ResponseWriter, message string) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(406)
json.NewEncoder(w).Encode(map[string]any{
"status": 406,
"error": "Not Acceptable",
"message": message,
})
}