Skip to main content
5xx Server Error

506 Variant Also Negotiates

The server has an internal configuration error resulting in a circular reference during content negotiation.

Meaning & Description

The 506 Variant Also Negotiates status code indicates a server misconfiguration in Transparent Content Negotiation. It occurs when a resource is requested, and the server selects a specific variant (like a localized version of a file) to serve based on the client's Accept headers. However, that chosen variant is itself configured as a negotiated resource rather than a proper end-point, causing a circular reference or infinite loop.

Common Causes

  • Misconfigured Apache `MultiViews` where multiple files reference each other in a loop.
  • A content negotiation algorithm resolving a variant that is just a pointer to another variant list.

How to fix a 506 error

  1. Check the Apache or Nginx configuration related to content negotiation (e.g., `Options +MultiViews`).
  2. Ensure that the files being negotiated (e.g., index.en.html, index.fr.html) are actual files and not symlinks pointing back to the directory or base file.

Browser & SEO Behaviour

Browser Behavior

Displays a generic 500-level error page. No special browser behavior exists.

SEO Impact

Functions identically to a 500 error. Search engines will pause crawling and eventually drop the page if not fixed.

CDN Behavior

Not cached. Passed directly to the client as an error.

Code Examples

HTTP
HTTP/1.1 506 Variant Also Negotiates
Content-Type: text/html

<html><body><h1>506 Variant Also Negotiates</h1><p>Internal configuration error.</p></body></html>
Node.js (Express)
app.get("/docs", (req, res) => {
  // Simulated scenario where negotiation fails due to circular reference
  const negotiationError = true;
  if (negotiationError) {
    return res.status(506).send("Variant Also Negotiates");
  }
});
Go (net/http)
package main

import "net/http"

func handler(w http.ResponseWriter, r *http.Request) {
	http.Error(w, "Variant Also Negotiates", 506)
}

func main() {
	http.HandleFunc("/", handler)
	http.ListenAndServe(":8080", nil)
}
Python (FastAPI)
from fastapi import FastAPI, HTTPException

app = FastAPI()

@app.get("/")
def read_root():
    raise HTTPException(status_code=506, detail="Variant Also Negotiates")
C# (ASP.NET Core)
[HttpGet("negotiate")]
public IActionResult Negotiate()
{
    return StatusCode(506, "Variant Also Negotiates");
}
curl
curl -i https://api.example.com/negotiation-loop

Raw HTTP Response Example

HTTP Response
HTTP/1.1 506 Variant Also Negotiates
Content-Type: application/json

{
  "error": "Variant Also Negotiates",
  "message": "Circular reference in content negotiation."
}

Real-world Examples

Apache HTTP Server: Returns a 506 when the `MultiViews` feature encounters a circular loop resolving a requested filename to its extensions.

Frequently Asked Questions

What is Transparent Content Negotiation?

It is a mechanism where a client asks for a resource (like an image), and the server looks at the client’s Accept headers (like Accept-Language or Accept-Encoding) to automatically serve the best matching file variant (like the French version or the WebP version).

How do I fix a 506 error in Apache?

Check your `MultiViews` configuration. Ensure you don’t have overlapping file names or type maps that point to each other circularly.

Is 506 common in modern APIs?

No. It is extremely rare and specific to traditional web servers performing filesystem-level content negotiation.

Did You Know?

The 506 status code was defined in an experimental RFC (RFC 2295) back in 1998 and is rarely seen in modern web development.

It is essentially the HTTP equivalent of a symbolic link loop on a Unix filesystem, but for content negotiation.

Developer Tips

  • If you are building an API, avoid returning 506. If your internal logic loops, returning a 500 Internal Server Error is much more standard and universally understood by monitoring tools.

Interview Questions

These are questions you might face in a backend or API design interview that touch on HTTP 506.

What causes a 506 Variant Also Negotiates error?

It is caused by a server misconfiguration in content negotiation where the chosen variant is not a final endpoint, but another negotiation list, causing an infinite loop.

Common Interview Mistakes

  • Assuming it has something to do with SSL/TLS negotiation. It strictly relates to HTTP content negotiation (e.g., choosing language or content-type variants).