HTTP 520 · 5XX Cloudflare Edge Cacheable: No Retryable: Yes (with backoff)

HTTP 520 Web Server Returned an Unknown Error: Root Causes & Production Fix Guide

Cloudflare Error 520 is a catch-all edge error triggered when your origin web server returns an empty response, resets the TCP connection unexpectedly, or sends invalid/oversized (>16KB) HTTP response headers.

Top Root Causes of HTTP 520

Diagnose Origin Directly (Bypassing Cloudflare) & Trim Headers

# 1. Hit origin IP directly with Host header to inspect raw response:
curl -i -sS --resolve example.com:443:ORIGIN_IP https://example.com/

# 2. In Nginx, keep response headers compact and disable debug leaks:
server_tokens off;
fastcgi_hide_header X-Powered-By;
proxy_hide_header X-Powered-By;

Verify with cURL

curl -i -sS --resolve example.com:443:203.0.113.10 https://example.com/

Interactive Stack Diagnoser (HTTP 520)

Frequently Asked Questions

How do I pinpoint the cause of Cloudflare 520?

Use `curl --resolve yourdomain.com:443:ORIGIN_IP https://yourdomain.com/` to test the origin directly and check origin error logs at the exact timestamp of the Cloudflare Ray ID.

Can oversized cookies cause Cloudflare 520?

Yes. If your origin emits response headers exceeding Cloudflare's 16KB header limit (e.g., dozens of `Set-Cookie` headers), Cloudflare aborts with 520.

Does enabling HTTP/2 to origin help with 520?

Checking SSL/TLS Full (Strict) and ensuring clean HTTP/1.1 or HTTP/2 framing on Nginx/Caddy eliminates most malformed-response 520s.

Related Status Guides & Header Tools