What is HTTP error code 520, and how do you fix it?
Error 520 is a Cloudflare-specific status code that means the origin server returned an empty, unknown, or unexpected response. It is not a standard HTTP code. Cloudflare reached your origin, but the reply was unparseable, so Cloudflare emits 520 as a catch-all for anything that doesn’t fit a more specific 5xx like 522 or 524.
Common causes
- Origin server or PHP application crash mid-request
- Firewall, WAF, or security plugin blocking Cloudflare’s IP ranges at origin
- Response headers exceeding 128 KB, usually from cookie bloat
- Empty response with no HTTP status line
- HTTP/2 misconfiguration at origin (ALPN announces support but the server breaks the protocol)
- Authenticated Origin Pull enabled on Cloudflare but origin not configured to accept the client cert
How to fix it
- Check origin error logs at the timestamp recorded in the
cf-rayID on the error page. - Whitelist Cloudflare’s published IP ranges in your firewall and any origin WAF or security plugin.
- Inspect response headers and trim oversized cookies.
- If HTTP/2 is enabled at origin, verify the configuration or disable HTTP/2-to-origin in Cloudflare’s Speed settings to rule it out.
- Switch the affected DNS record to grey-cloud (DNS-only). If 520 disappears, the cause sits between Cloudflare and the origin. If it persists, the origin is the source.
- If unresolved, open a ticket with your host. Include the
cf-rayID and a HAR file captured during the failure.
Related articles
All articles →Bypass Cloudflare 1020: The Ultimate Guide for Web Scrapers (2026)
Tired of 'Access Denied'? Go beyond basic fixes. This guide teaches you how to bypass Cloudflare 1020 by mastering TLS fingerprinting, headers & stealth browsers.
How To Retry Failed Python Requests
Learn how to implement retry mechanisms in Python Requests to handle timeout errors, HTTP status codes like 403, 429, 500, 502, 503, and 504, and avoid infinite loops with effective backoff strategies.
How to Use cURL in Python
cURL is a handy query utility that supports most transfer protocols. The LibcURL API was created for its use in one's own programs. And for use in Python was created a thin wrapper above libcURL which is called PycURL.
Stop debugging blocked requests one by one
HasData handles rotation, rendering, and retries, so most blocked targets come back as data instead of error codes.