Qaynaq LABS · TOOLS

HTTP · 5xx Server Error

506 Variant Also Negotiates

Server cannot properly negotiate the requested variant due to circular references in content negotiation.

When you see this status

  • Client requests a resource with complex content negotiation
  • Server detects circular dependencies in negotiated variants
  • Proxy misconfigures variant negotiation headers

Common causes

  • Circular $ref in OpenAPI/Swagger specs
  • Improper Vary header configuration
  • Misconfigured content negotiation middleware
  • Server-side variant resolution loops

How to debug it

  1. Inspect request headers for Accept, Accept-Charset, Accept-Encoding
  2. Check server logs for variant resolution attempts
  3. Validate OpenAPI/Swagger definitions for circular references
  4. Review proxy or CDN variant handling configuration

Return this code in your framework

Express (Node.js)
res.status(506).send('Variant Also Negotiates');
FastAPI (Python)
from fastapi import status
return JSONResponse(status_code=status.HTTP_506_VARIANT_ALSO_NEGOTIATES, content={"error": "Variant negotiation failed"})
NestJS
@Get() getVariant() { throw new HttpException('Variant negotiation failed', HttpStatus.VARIANT_ALSO_NEGOTIATES); }
Go (net/http)
http.Error(w, "Variant Also Negotiates", http.StatusVariantAlsoNegotiates)

About HTTP 506

HTTP status code 506 Variant Also Negotiates is part of the 5xx Server Error family. Server cannot properly negotiate the requested variant due to circular references in content negotiation. Understanding it is essential for backend engineers, API designers, and anyone debugging integrations between services.

The Qaynaq Labs HTTP Status Code Explainer covers all standard codes with practical guidance: what triggers them, how to debug them in production, and exactly how to return them from common frameworks. Each code page is hand-curated and verified.

Frequently asked

Why does 506 occur with OpenAPI/Swagger?

Circular $ref references in the spec cause infinite variant resolution loops during negotiation.

Can proxies trigger 506?

Yes, if a proxy misconfigures Vary headers or variant resolution, it may return 506 to clients.

How to fix 506 in Express?

Simplify content negotiation logic or remove circular variant dependencies in middleware configuration.