506

Variant Also Negotiates

Official
Endpoint negotiates itself

General explanation of the 506 status code

The HTTP status code 506 Variant Also Negotiates is an indicator of a specific problem within a server that occurs when the server is deployed in a configuration that uses so-called transparent content negotiation. This type of content negotiation is used to manage different versions of a resource that can be delivered depending on the requirements of the requesting client (e.g. different languages, file formats or encodings).

In essence, the 506 Variant Also Negotiates status code means that there is a misconfiguration on the server that leads to an infinite loop of negotiation. Instead of the server selecting a specific version of the requested resource based on the client's preferences, the selection itself refers to another negotiation. The result is that none of the variants are delivered because the server is caught in a cycle of references where one variant refers to another, which in turn refers to another, and so on.

A simple example: a client wants a web page in a specific language. The server has different language versions of the website and tries to select the most suitable version. However, if the configuration of the server is incorrect, the process that is supposed to select the most suitable version could instead refer to another round of negotiations instead of making a definitive selection. The 506 Variant Also Negotiates status code signals to the client that the server is unable to deliver an appropriate version of the resource due to these internal conflicts or misconfigurations.

In practice, this status code is rarely seen because it assumes a very specific server configuration and error condition. Resolving the issue requires a review and correction of the server configuration to ensure that content negotiation can be performed correctly without entering an infinite loop.

Specification of the HTTP status code 506

The 506 Variant Also Negotiates status code indicates that the server has an internal configuration error: the chosen variant resource is configured to engage in transparent content negotiation itself, and is therefore not a proper end point in the negotiation process.

Source / Quote by: The 506 Variant Also Negotiates HTTP Status Code is specified by section 8.1 of RFC2295.

How to throw a 506 statuscode with PHP?

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

Test the 506 HTTP status code

In order to be able to display the HTTP status code (in this case 506 Variant Also Negotiates) 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 506 Variant Also Negotiates
Overview
URL: https://http-statuscode.com/errorCodeExample.php?code=506
Status: 506 Variant Also Negotiates
Those: Network
IP address: XX.XX.XX.XX
Status code 506 Variant Also Negotiates

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

Creating your own 506 Variant Also Negotiates 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 506 Variant Also Negotiates error page in "Apache", the following change must be made in the following file.

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

NGINX Webserver

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

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

Browser compatibility of the 506 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

http.StatusVariantAlsoNegotiates
Response::HTTP_VARIANT_ALSO_NEGOTIATES_EXPERIMENTAL
:variant_also_negotiates
Author: Tony Brüser
Author: Tony Brüser

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

LinkedInGitHub