520, 521, 522 and 524 at a glance: the site's side in every normal case.
| Code | Cause, in one line (Cloudflare) | The number to know | Your scraper's fault? |
|---|---|---|---|
| 520 | the site's server sent an empty, malformed or unexpected answer | response headers over 128 KB are one cause | No |
| 521 | the site's server is down or refuses Cloudflare's connection | – | No |
| 522 | the site's server is overloaded, down or blocking Cloudflare, so the connection timed out | no SYN+ACK within 19 s, or no acknowledgment within 90 s | No; many threads on one host can add load |
| 524 | the site's server connected but sent no HTTP response in time | 125 s, the default timeout | Rarely; only by hammering a heavy page |
On this page 8 sections
Which Cloudflare errors a proxy can fix
Every Cloudflare error falls into one of four groups: access denied, rate limiting, challenges, and origin and DNS errors. A proxy changes only your IP, network and country, so it helps only where the rule checks one of those.
| Group | Codes | Who caused it | Proxy helps? (ProxyField's assessment) | What really fixes it |
|---|---|---|---|---|
| Access denied | 1005 (network banned) | the site bans your network (ASN) | Often | an IP from a residential or mobile network |
| Access denied | 1006-1008, 1106 (IP banned) | the site bans your IP | Yes | a new IP |
| Access denied | 1009 (country banned) | the site bans your country or region | Yes, where use from another country is allowed | country targeting |
| Access denied | 1010 (browser signature) | the site bans your client's signature | No | a real, current browser with consistent headers |
| Access denied | 1012 (access denied) | a site rule refused the request | Rarely | send the Ray ID to the site owner |
| Access denied | 1020 (custom rule) | a custom firewall rule matched | Depends on the field the rule checks | find that field: IP, country, user agent, path |
| Rate limiting | 1015, HTTP 429 | you passed the site's request limit | Partly | a slower pace and the Retry-After wait first; rotation spreads per-IP counts |
| Challenges | HTTP 403 with cf-mitigated: challenge, "Just a moment..." | Cloudflare wants a real browser | No, not alone | a real browser session that runs the page, as a visitor's would |
| Origin and DNS | 502-530, 1000-1004, 1016, 1018 | the website's server or its Cloudflare setup | No | waiting; the site owner |
| Not Cloudflare | 401, 404 | a missing login, or a wrong URL | No | the right credentials or URL |
Codes, titles and HTTP statuses are Cloudflare's (1xxx errors, 5xx errors); the "Proxy helps?" column is ProxyField's assessment, not Cloudflare's. The rule of thumb: repeated 403, 429 or 10xx pages mean the site is limiting you; 52x pages mean the site is broken. For 429 and Retry-After, see 429 Too Many Requests; for what a proxy cannot change in general, see what proxies can and cannot fix.
How to read a Cloudflare error page
- The number. "Error 1020", "Error 522" and so on. It names the rule or the failure; Cloudflare documents each one under HTTP status codes.
- The Ray ID. A reference for that request, also sent as the
cf-rayresponse header. You can't decode it, but the site owner can look it up in their Cloudflare account, so include it when you report a block. - The diagram (on 52x pages). It shows "You", "Cloudflare" and "Host" (the website's server) and marks which link failed, usually "Host: Error".
The 10xx number sits in the HTML body; the HTTP status underneath is a normal one: 403 for most blocks, 429 for 1015, 409 or 530 for some DNS and setup errors, 5xx for server failures. Your scraper sees the status; the page body has the Cloudflare number.
Tell the errors apart in your scraper
Log four things per failed response: the status, the cf-mitigated header (Cloudflare sets it to challenge on every challenge page), the Retry-After header, and the error number in the body.
import re
import requests
PROXY = "http://<login>-country-us-city-new_york:<password>@gate.proxyfield.io:7000"
r = requests.get("https://example.com/", proxies={"http": PROXY, "https": PROXY}, timeout=30)
code = re.search(r"Error (1\d{3}|5\d{2})", r.text)
print(r.status_code, # 403, 429, 52x ...
r.headers.get("cf-mitigated"), # "challenge" on a challenge page
r.headers.get("retry-after"), # seconds to wait after a 429
r.headers.get("cf-ray"), # the Ray ID for the site owner
code.group(1) if code else None) # the Cloudflare number, e.g. 1020 or 522The same check with cURL: curl -s -o /dev/null -D - https://example.com/ | grep -i -E '^(HTTP|cf-|retry-after)'.
| You see | It is | Next step |
|---|---|---|
403 and cf-mitigated: challenge | a challenge page | a real browser; a new IP alone won't do |
| 403 and "Error 1005", "1006"-"1009" in the body | an IP, network or country ban | another IP, network or country |
| 403 and "Error 1010" or "1020" | a signature or custom rule | a real browser; find the field the rule checks |
| 429, or "Error 1015" | rate limiting | wait for Retry-After, then slow down |
| 520-526 | the site's server | retry later with back-off |
Cloudflare 10xx errors
The 10xx codes visitors and scrapers trigger, with Cloudflare's titles and HTTP statuses (1xxx errors):
| Code | Cloudflare's title | HTTP status | Short fix |
|---|---|---|---|
| 1005 | Access Denied: Autonomous System Number (ASN) banned | 403 | Another network, such as a residential IP |
| 1006, 1007, 1008, 1106 | Access Denied: Your IP address has been banned | 403 | Another IP; ask the owner if it is a mistake |
| 1009 | Access Denied: Country or region banned | 403 | An IP in a country the site serves |
| 1010 | The owner of this website has banned your access based on your browser's signature | 403 | A real, current browser; consistent headers |
| 1012 | Access Denied | 403 | A site rule refused the request; send the Ray ID to the owner |
| 1015 | You are being rate limited | 429 | Wait, then slow down |
| 1020 | Access denied | 403 | Find which field the custom rule checks |
Each of these, with step-by-step fixes, is in Cloudflare access denied errors. The other 10xx codes are configuration problems on the site's side: 1000 (DNS points to prohibited IP, 403), 1001 (DNS resolution error, 409), 1003 (direct IP access not allowed, 403), 1016 (origin DNS error, 530) and 1018 (could not find host, 409).
Are 520, 521, 522 and 524 my scraper's fault or the site's?
The site's, in every normal case; a scraper contributes only by overloading a heavy page with many threads. A 5xx page means your request reached Cloudflare and the failure is between Cloudflare and the website's server. If the site were blocking you on purpose, you would see 403, 429 or a 10xx number instead.
How to tell the cases apart in your logs:
| Pattern | Whose side | What to do |
|---|---|---|
| 52x on every URL of the site, also from a normal browser on another network | the site's server or its Cloudflare setup | wait and retry later |
| 52x only on one heavy page, only when you run many threads | your load adds to a slow server | lower the concurrency on that host and back off |
| 52x on many unrelated sites at once | Cloudflare itself | check Cloudflare's status page |
| 403, 429 or a 10xx number instead | you are being limited, not a server failure | see the table above |
One check settles most cases: load the same URL a few minutes later from a normal browser on another network. If it fails there too, it is the site.
Cloudflare 5xx errors: 502 to 530
| Code | Cloudflare's title | Typical causes (Cloudflare) | Your scraper's fault? |
|---|---|---|---|
| 502 / 504 | Bad gateway / gateway timeout | no valid or timely answer from the site's server | No |
| 503 | Service temporarily unavailable | the service is overloaded or down | No; retry later |
| 520 | Web server returns an unknown error | the server crashed or is misconfigured; an empty or malformed answer, or one without proper headers; a firewall or security plugin blocks Cloudflare's IPs; response headers over 128 KB (often too many cookies); a wrong HTTP/2 setup at the server; Authenticated Origin Pull turned on without the server set up for it | No |
| 521 | Web server is down | the web server application is offline, or the server blocks Cloudflare's requests | No |
| 522 | Connection timed out | the server is overloaded, down or blocking Cloudflare, so there is no SYN+ACK within 19 seconds or no acknowledgment of the request within 90 seconds | No; if you run many threads on that host, lower the concurrency and retry after 30 s, then 60 s, then 120 s |
| 523 | Origin is unreachable | Cloudflare could not reach the site's server at all | No |
| 524 | A timeout occurred | the server accepted the connection but sent no HTTP response within the default 125 seconds: a slow query, too much work, too few resources | Rarely: only if your requests overload a heavy page; back off the same way |
| 525 | SSL handshake failed | TLS between Cloudflare and the site's server failed | No |
| 526 | Invalid SSL certificate | the site's server has an invalid certificate | No |
| 530 | (with 1016 or 1033 in the body) | origin DNS error or a tunnel error | No |
Titles and causes from Cloudflare's per-code pages. None of these is caused by your proxy, your IP or your scraper's headers, so changing them does nothing. What you can do as a scraper:
- Retry later, with back-off (for example 30 s, then 60 s, then 120 s; this pattern is ordinary practice, not a Cloudflare figure), and stop after a few tries.
- Check whether the whole site is down from another network or a normal browser; if it is, wait.
- Check Cloudflare's status page when many unrelated sites fail at once.
If you run the site, Cloudflare's 520 page gives these checks:
- As a temporary workaround, set the affected DNS record to DNS-only, or pause Cloudflare, and see whether the error follows the server.
- Turn off HTTP/2 to Origin under Speed > Settings > Protocol Optimization if the server's HTTP/2 setup is in doubt.
- In Origin Analytics, compare
originResponseStatuswithedgeResponseStatus: a 200 from the server served as a 520 means a malformed answer, such as oversized headers or an early close. - In Logpush,
OriginResponseStatus0 is a failed connection only whenCacheStatusis "miss" or "expired". - For support, send the URL, the Ray ID, the output of
/cdn-cgi/traceon your domain and two HAR files, one with Cloudflare on and one with it paused.
For a 403 with a Cloudflare page, start with Cloudflare 403 Forbidden. For why Cloudflare challenges a client in the first place, see why Cloudflare thinks you are a bot.
Seeing a Cloudflare error as a visitor
- A 10xx page: turn off your VPN or proxy, update your browser, pause extensions, and wait a few minutes after a 1015. If it persists, send the Ray ID to the site owner.
- A 52x page: the site is having problems. Reload in a few minutes; nothing on your device causes it.
- A "Just a moment..." page that loops: allow JavaScript and cookies for the site and try another browser.
Cloudflare Error Codes FAQ
What do Cloudflare error codes mean when I'm scraping, and which of them can a proxy actually fix?
ProxyField sorts Cloudflare errors into 4 groups: access denied (1005, 1006 to 1010, 1012, 1020), rate limiting (1015 and 429), challenges (403 with cf-mitigated: challenge) and origin errors (502 to 530). A proxy fixes only the IP-based blocks: 1005 (network), 1006 to 1008 (IP), 1009 (country) and part of 1015 rate limits. It does not fix 1010, challenge pages without a real browser, 401, 404 or any 52x error.
What causes Cloudflare errors 520, 521, 522 and 524, and are they my scraper's fault or the site's?
The site's, in every normal case: 520 is an empty or malformed answer from the server (a crash, headers over 128 KB, a wrong HTTP/2 setup), 521 a server that is down or blocks Cloudflare, 522 an overloaded or blocking server that did not answer within 19 or 90 seconds, and 524 no response within 125 seconds. Your scraper can add to a 522 or 524 only by hammering a heavy page with many threads. If you are being blocked, you see 403, 429 or 10xx pages instead.
What does a Cloudflare error mean?
The website uses Cloudflare, and either one of its Cloudflare rules blocked your request or Cloudflare could not get an answer from the website's server. The code on the page tells you which.
How do I fix a Cloudflare error?
Read the code first. For 10xx blocks, change what the rule checks (VPN or proxy, browser, pace) or ask the site owner with the Ray ID; for 52x errors, wait and retry, because the website's server has to recover.
What are the most common Cloudflare error codes when scraping?
403 block and challenge pages, 1020 (a custom firewall rule), 1015 (rate limiting), 1010 (browser signature) and 1005 or 1009 (network or country bans). 52x codes show up too, but they mean the site's server failed, not that you were blocked.
How can my scraper tell which Cloudflare error it got?
Log the HTTP status, the cf-mitigated header, the Retry-After header and the "Error NNNN" number in the body. cf-mitigated: challenge marks a challenge page, 429 or 1015 marks rate limiting, 1005 to 1020 in a 403 body marks a rule, and 52x marks the site's server.
What is a Cloudflare 520 error?
Cloudflare's title is "Web server returns an unknown error": the website's server sent an empty, malformed or unexpected answer, often after a crash or with response headers over 128 KB. It's on the site's side; retry later.
What is Cloudflare error 521?
"Web server is down": the website's server application is offline or blocks Cloudflare's requests. Only the site owner can fix it; wait and retry.
What is Cloudflare error 522?
"Connection timed out": the website's server did not answer Cloudflare's connection within 19 seconds, or did not acknowledge the request within 90 seconds. The server is overloaded, down or blocking Cloudflare, so the fix is on the site's side.
What is Cloudflare error 524?
"A timeout occurred": the website's server accepted Cloudflare's connection but did not answer within the default 125 seconds. Heavy pages or overloaded servers cause it; retry later and don't hammer the page.
Show 2 more questionsShow fewer questions
What errors are caused by Cloudflare downtime?
When Cloudflare itself has an incident, many unrelated sites show 5xx errors at the same time. Check Cloudflare's status page; if an incident is listed, nothing on your side or the website's will fix it until Cloudflare does.
Why does a Cloudflare page say "failed"?
On 52x pages, Cloudflare's diagram shows your browser, Cloudflare and the website's server and marks the failed link, usually "Host: Error". That means the website's server failed, not your connection.