Not Acceptable

Official Substatus codes
The user agent does not have an accepted representation

Specification of the HTTP status code 406

The 406 Not Acceptable status code indicates that the target resource does not have a current representation that would be acceptable to the user agent, according to the proactive negotiation header fields received in the request, and the server is unwilling to supply a default representation. The server SHOULD generate a payload containing a list of available representation characteristics and corresponding resource identifiers from which the user or user agent can choose the one most appropriate. A user agent MAY automatically select the most appropriate choice from that list.

Source / Quote by: The 406 Not Acceptable HTTP Status Code is specified by section 6.5.6 of RFC7231.

How to throw a 406 statuscode with PHP?

To throw the HTTP status code 406 on a web page, the PHP function http_response_code can be used. The syntax is as follows: http_response_code(406) (PHP 5 >= 5.4.0, PHP 7, PHP 8)

Test the 406 HTTP status code

In order to be able to display the HTTP status code (in this case 406 Not Acceptable) and other information on the client side, the development console must be opened with F12. Afterwards you have to navigate to the tab "Network". Now you can open the page, in the network tab you should see the web page (example index.php). This must be selected and then the Herder section must be selected. Here the user will see the following result:

Status code 406 Not Acceptable
URL: https://http-statuscode.com/errorCodeExample.php?code=406
Status: 406 Not Acceptable
Those: Network
IP address: XX.XX.XX.XX
Status code 406 Not Acceptable

How to create a custom error page for the 406 status code

Creating your own 406 Not Acceptable error page is relatively easy with the web server "Apache" as well as with the web server "NGINX".

Apache Webserver

The web server "Apache" is one of the most popular web servers on the Internet. To create an own 406 Not Acceptable error page in "Apache", the following change must be made in the following file.

File: .htaccess
ErrorDocument 406 /errors/406.html

NGINX Webserver

Similar to the web server "Apache", "NGINX" is also widely used on the Internet. To create your own 406 Not Acceptable error page in "NGINX", the following change must be made in the following file.

File: sites-enabled/default
error_page 406 /406.html;
location = /406.html {
    root /usr/share/nginx/html;

Browser compatibility of the 406 status code

Chrome no data
Edge no data
Firefox no data
Opera no data
Safari no data
Chrome Android no data
Firefox for Android no data
Opera Android no data
Safari on iOS no data
Internet no data
WebView Android no data

Constants in programming languages


Sub status codes of the 406 status code

Sub status codes are purely technical, and should never be sent to the user. For example, if status code 406.1 is thrown, it may be logged, but status code 406 will be sent to the user.:
406.0 Invalid MIME type
HTTP IIS, Unofficial
Author: Tony Brüser
Author: Tony Brüser

Tony Brüser is an enthusiastic web developer with a penchant for HTTP status codes.