5xx Cloudflare & Edge Error

HTTP 520 Web Server Returned an Unknown Error — Reverse Proxy & Gateway Troubleshooting

Error 520 is a Cloudflare-specific edge error triggered when the origin web server closes a reused TCP connection with an empty response, TCP RST, malformed HTTP header, or response headers exceeding Cloudflare's 16 KiB–32 KiB limit.

Status Code520 Web Server Returned an Unknown Error
Specification / OriginCloudflare Edge Code 520
Failure LayerCloudflare Edge -> Origin TCP/HTTP
Retry SafetySafe for idempotent GET/HEAD with exponential backoff + jitter

Interactive HTTP 520 Live Probe & Log Command Builder

Enter your target endpoint below to generate copy-ready curl latency breakdown probes and origin bypass tests:


  

Related diagnostics: Nginx & Caddy Proxy Generator → · X.509 SSL Certificate Decoder → · Offline JWT Expiry Inspector →

Production Root Causes & Remediation Guide

Most commonly caused by origin KeepAliveTimeout being too short (e.g., Apache 5s default) relative to Cloudflare's connection pooling, crashing PHP-FPM/Node workers mid-header, or origin firewalls resetting high-rate Cloudflare proxy IPs.

Step-by-Step Engineering Fix

Set origin HTTP keep-alive timeouts to at least 60–90 seconds (keepalive_timeout 75s in Nginx), audit large Set-Cookie headers, and allowlist official Cloudflare IPv4/IPv6 CIDR ranges free from connection rate limits.

Recommended Nginx / Reverse-Proxy Configuration Snippet

keepalive_timeout 75s;
keepalive_requests 1000;

Frequently Asked Questions (HTTP 520)

How do you quickly fix sporadic Cloudflare 520 errors on Nginx or Apache?

Raise KeepAliveTimeout to 65s+ on Apache/Nginx and ensure no local fail2ban, iptables connlimit, or cloud firewall throttles Cloudflare edge proxy CIDRs.

Which infrastructure layer generates HTTP 520 Web Server Returned an Unknown Error?

HTTP 520 (Cloudflare Edge Code 520) typically originates at the Cloudflare Edge -> Origin TCP/HTTP layer. Error 520 is a Cloudflare-specific edge error triggered when the origin web server closes a reused TCP connection with an empty response, TCP RST, malformed HTTP header, or response headers exceeding Cloudflare's 16 KiB–32 KiB limit.

Should API clients automatically retry HTTP 520 responses?

HTTP 520 is safe to retry ONLY for idempotent methods (such as GET or HEAD) using exponential backoff with random jitter.

Browse All 25 Gateway, Proxy & Cloud HTTP Error Guides

HTTP 400 (Bad Request) HTTP 401 (Unauthorized) HTTP 403 (Forbidden) HTTP 404 (Not Found) HTTP 405 (Method Not Allowed) HTTP 408 (Request Timeout) HTTP 413 (Content Too Large) HTTP 422 (Unprocessable Content) HTTP 429 (Too Many Requests) HTTP 431 (Request Header Fields Too Large) HTTP 499 (Client Closed Request) HTTP 500 (Internal Server Error) HTTP 501 (Not Implemented) HTTP 502 (Bad Gateway) HTTP 503 (Service Unavailable) HTTP 504 (Gateway Timeout) HTTP 507 (Insufficient Storage) HTTP 511 (Network Authentication Required) HTTP 520 (Web Server Returned an Unknown Error) HTTP 521 (Web Server Is Down) HTTP 522 (Connection Timed Out) HTTP 523 (Origin Is Unreachable) HTTP 524 (A Timeout Occurred) HTTP 525 (SSL Handshake Failed) HTTP 526 (Invalid SSL Certificate)

Copied to clipboard