HTTP

HTTP 502 Bad Gateway vs 506 Variant Also Negotiates

Both HTTP 502 (Bad Gateway) and 506 (Variant Also Negotiates) belong to the 5xx Server Error category. 502 indicates that the server, acting as a gateway or proxy, received an invalid response from the upstream server. Meanwhile, 506 means that the server has an internal configuration error: the chosen variant resource is configured to engage in content negotiation itself.

Description

The server, acting as a gateway or proxy, received an invalid response from the upstream server.

When You See It

When Nginx/Apache can't reach the application server (e.g., Gunicorn is down, upstream timeout).

How to Fix

Check if the upstream server is running. Verify proxy configuration. Check for upstream timeouts.

Description

The server has an internal configuration error: the chosen variant resource is configured to engage in content negotiation itself.

When You See It

Rare. Indicates a misconfigured server-side content negotiation loop.

How to Fix

Fix the server's content negotiation configuration.

Key Differences

1.

HTTP 502: The server, acting as a gateway or proxy, received an invalid response from the upstream server.

2.

HTTP 506: The server has an internal configuration error: the chosen variant resource is configured to engage in content negotiation itself.

3.

You encounter 502 when when Nginx/Apache can't reach the application server (e.g., Gunicorn is down, upstream timeout).

4.

You encounter 506 when rare. Indicates a misconfigured server-side content negotiation loop.

When to Use Which

For 502 (Bad Gateway): Check if the upstream server is running. Verify proxy configuration. Check for upstream timeouts. For 506 (Variant Also Negotiates): Fix the server's content negotiation configuration.

Learn More