What 520 means
520 is not a standard HTTP status code. Cloudflare sends it, from its edge, when the origin server returned something it couldn't use: an empty, unknown or unexpected response. It's Cloudflare's catch-all for "the connection to the origin worked, but what came back wasn't a valid HTTP answer". Your own server never sent 520; Cloudflare generated it on your server's behalf.
HTTP/2 520
server: cloudflare
cf-ray: 8c1f2a3b4d5e6f70-AMS
content-type: text/html
<title>example.com | 520: Web server is returning an unknown error</title>
The cf-ray ID identifies the request in Cloudflare's logs and is what Cloudflare support asks for.
Common causes
The usual causes:
- The origin crashed or reset the connection after accepting it, for example a PHP or application process dying mid-request.
- An empty response: no status line and no headers.
- Response headers too large, typically from too many or very large cookies.
- Invalid HTTP: a missing status code or malformed headers from a custom or misconfigured server.
- A firewall or security module (fail2ban, mod_security, a host-level DDoS filter) that cuts Cloudflare's connections because many requests come from few IPs.
- HTTP/2 to the origin misbehaving, when origin HTTP/2 is enabled.
How to fix it
-
Read the origin's logs at the time of the error: the web server's error log and the application log. Search for the URL and the minute shown on the error page.
-
Bypass Cloudflare to test the origin. Send the request straight to the origin IP with the host name you expect:
curl -svo /dev/null --resolve example.com:443:203.0.113.10 https://example.com/If this also fails or returns nothing, the problem is on the origin, not at Cloudflare.
-
Allowlist Cloudflare's IP ranges (published at
cloudflare.com/ips) in the server firewall, fail2ban and any rate limiter, and restore real visitor IPs withmod_remoteipor nginx'sreal_ip_header CF-Connecting-IPso blocks target visitors, not Cloudflare. -
Shrink the headers: cut down cookies and long custom headers if the response headers are large.
-
If origin HTTP/2 is enabled and the errors started with it, turn it off to test.
-
If the origin looks healthy, open a ticket with Cloudflare including the
cf-rayIDs and a HAR file.
520 and SEO
Googlebot sees the 520 status, which is in the 5xx range, so it's handled like any server error: crawling slows down while errors continue, and URLs that fail for a long time are eventually dropped from the index. Intermittent 520s under load are easy to miss in a browser; Search Console's crawl stats report shows them as server errors.
Related codes
- 521 Web Server Is Down: the origin refused the connection outright.
- 502 Bad Gateway: the standard code for an invalid upstream response.
- 522 Connection Timed Out: the connection to the origin never completed.
- 524 A Timeout Occurred: connected, but no answer within 100 seconds.
Check what visitors get from the edge with the Redirect Checker, or inspect the full response headers with the HTTP Request Builder.