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 →Cloudflare Error 1020: Causes and Fixes (2026)
What triggers Cloudflare Error 1020, and the proxy, header, pacing, and headless-browser techniques that reduce it when scraping.
How To Retry Failed Python Requests
Configure retries for Python requests with urllib3 Retry and Tenacity: timeouts, status_forcelist, backoff, and a 600-request test of what retries actually rescue.
How to Use cURL in Python
Run a curl command in Python by translating it. Copy as cURL, a flag-to-requests table, 47 real commands replayed four ways, and when curl_cffi or PycURL fits.
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.