Introducing /monitor. Notify your AI agent the moment pages or sites change. Try it now →

What is a 520 status code and how to avoid it?

TL;DR

A 520 error means Cloudflare couldn't get a valid response from the origin server. It's Cloudflare-specific, not a standard HTTP code. Avoid it by using proper request headers, respecting rate limits, and implementing retry logic.

What is a 520 status code and how to avoid it?

A 520 error is Cloudflare-specific, meaning "Unknown Error" or "Web Server Returned an Unknown Error." It occurs when Cloudflare successfully connects to the origin server but receives an unexpected or empty response. This happens when servers are overloaded, misconfigured, or when they detect and block suspicious requests. It's not a standard HTTP status code—only appears with Cloudflare-protected sites.

Why 520 errors occur

Origin servers return invalid responses when overloaded by requests, detect bot-like behavior, have misconfigurations blocking Cloudflare IPs, crash or timeout under load, or return empty responses to suspicious traffic.

For scrapers, 520s often indicate your requests look automated—missing headers, unusual patterns, or too many requests too quickly. The server tells Cloudflare "something's wrong" without specifying what.

How to avoid 520 errors

Use complete, realistic request headers including User-Agent, Accept, and Accept-Language. Respect rate limits—space requests like a human (few seconds between requests). Implement retry logic with exponential backoff—temporary overload often resolves quickly.

Use residential proxies instead of datacenter IPs—they're less likely to trigger anti-bot systems. Rotate user agents and headers to avoid fingerprinting. Monitor for patterns—if 520s spike, you're likely triggering protection.

Key Takeaways

520 errors are Cloudflare-specific, indicating the origin server returned an invalid response. Often triggered by bot detection—missing headers, aggressive rate limiting, or suspicious patterns. Avoid by using proper headers, respecting rate limits, and implementing retries.

Last updated: Jan 26, 2026