HTTP status code 406 indicates that the server cannot provide a suitable response based on the content characteristics (such as language, encoding, etc.) requested by the client. The server, in attempting to perform content negotiation, did not find any suitable content that meets the standards specified by the user agent, and therefore cannot fulfill the client’s request.
Common Solutions for 406 Error
-
Check Request Headers: Ensure that the request headers sent by the client, such as
Accept
,Accept-Charset
,Accept-Encoding
, andAccept-Language
, match the resources the server can provide. If the requested content characteristics are not supported by the server, these headers may need to be modified. -
Modify Server Configuration: Server administrators can review the server configuration to ensure it can generate the content types requested by the client. For example, in an Apache server, the configuration file can be adjusted to add or modify MIME types.
-
Update Client Settings: Users can check and update their browser or client application’s language and character set settings to align with the options supported by the server.
-
Inspect Web Application Code: If the issue occurs within a specific web application, the application code should be examined to ensure it correctly handles content negotiation and response headers.
-
Use Appropriate Response Format: Ensure that the data format returned by the server is one that the client can parse. For example, if the client expects data in JSON format, the server should return the
Content-Type: application/json
response header and ensure the response body is valid JSON. -
Introduce JSON Parsing Library: If the 406 error occurs in a programming environment, ensure that the appropriate JSON parsing libraries (such as Jackson or Fastjson) are included and that the MVC framework (like Spring MVC) is correctly configured to support JSON responses.
-
Check API and Web Services: If interacting through an API or web service, check the API documentation to ensure that the request format and expected response format are consistent.
-
Analyze Server Logs: Server-side logs can provide detailed information about request handling, and analyzing these logs can help diagnose the issue’s cause.
If the problem persists, further technical support may be needed to diagnose and resolve the issue.
Related 4xx error code
- 400 Bad Request
- 401 Unauthorized
- 402 Payment Required
- 403 Forbidden
- 404 Not Found
- 405 Method Not Allowed
- 407 Proxy Authentication Required
- 408 Request Timeout
- 409 Conflict
- 410 Gone
- 411 Length Required
- 412 Precondition Failed
- 413 Payload Too Large
- 414 URI Too Long
- 415 Unsupported Media Type
- 416 Range Not Satisfiable
- 417 Expectation Failed
- 418 I’m a teapot
- 421 Misdirected Request
- 422 Unprocessable Entity (WebDAV)
- 423 Locked (WebDAV)
- 424 Failed Dependency (WebDAV)
- 425 Too Early
- 426 Upgrade Required
- 428 Precondition Required
- 429 Too Many Requests
- 431 Request Header Fields Too Large
- 451 Unavailable For Legal Reasons
- 499 Client Closed Request