Error code 520: how to solve it when web scraping

Is your web scraper getting 520 status codes? Solve them with this quick guide.

Running into Cloudflare Error 520, also known as HTTP response status code 520, shouldn't throw a wrench in your web scraping plans. But knowing what it means and how to deal with it can save you some headaches.

What is error 520?

The HTTP response status code 520, known as "Web server returned unknown error" is a server-side error that is normally associated with Cloudflare. 520 usually indicates that the connection to the origin web server was successful, but the server returned an empty or unknown response. It's like encountering a digital dead end on the web.

What is error 520? Could be just a glitch in your scraping matrix.
What is status code 520? Could be just a glitch in your scraping matrix.

Why 520 error is common when web scraping

Error code 520 can disrupt web scraping projects because it signifies a breakdown in communication between your scraper and the web server but doesn't provide a detailed reason for why that breakdown occurred. Just look at the wording of 520 status code – it's incredibly vague. The disruption of an unknown type could be simply an attempt to block your scraper.

Unlike client-side errors like 403, 499, or 444, server-side errors like 520 occur on the web server itself and are typically caused by issues such as server overload and configuration errors in case of an accident, or security measures implemented by services like Cloudflare in case of deliberate blocking.

The most common causes of HTTP 520 error

1. Server overload

At times when the origin server is overwhelmed by incoming requests, it may struggle to respond effectively, resulting in a 520 status code on your side.

2. Overprotective firewall

Cloudflare's firewall settings may interpret certain requests as malicious and terminate connections abruptly.

3. DDoS protection

Sometimes, Cloudflare's DDoS protection mechanisms can misinterpret legitimate traffic spikes as malicious attacks and result in false positives, your web crawler among them.

How to solve Cloudflare 520 error

1. Check the origin server

If you're the website admin, make sure the server on the other end isn't taking a siesta. If it's just a hiccup, waiting it out might do the trick.

2. Tweak Cloudflare settings

Same here, if you are the website owner, take a look at your Cloudflare settings and dial down the firewall if it's being too strict. You don't want it blocking legitimate website requests.

3. Scrape smart

Minimizing the strain on web servers and adhering to Cloudflare's guidelines should be in all web scraping rule books. Even basic rate limiting, using proxies, or keeping your user-agents variable can help mitigate the risk of encountering error 520.

How to deal with Cloudflare error 1020

In addition to error 520, web scrapers may also encounter Cloudflare error 1020. Unlike 520, the 1020 error leaves no doubt that your request has been blocked by Cloudflare's security settings. To address this issue, you may need to adjust your scraping tactics to comply with Cloudflare's security protocols and avoid triggering further blocks.

Want to read up on how to avoid anti-scraping protections? See our Docs.


The ambiguity of error code 520 might throw you off your game, but with a bit of scraping know-how, you can handle it. Understand what's causing the issue, tweak your approach if needed, and keep on scraping.

On this page

Build the scraper you want

No credit card required

Start building