Errors and troubleshooting
What is Cloudflare error 522?
It means Cloudflare's edge tried to open a connection to the website's own server and gave up waiting, so the fault sits between Cloudflare and the origin, not with your request.
The meaning
Cloudflare sits in front of many sites as a reverse proxy: you connect to Cloudflare, and Cloudflare connects to the site's origin server. Error 522, "Connection timed out", means the second connection never completed. Cloudflare sent the TCP handshake to the origin and did not get an answer in time. The page you see is generated by Cloudflare and names three parties: your browser (working), Cloudflare (working) and the host (error).
Is it about you?
Almost never. A 522 is not a bot block and not a CAPTCHA. Cloudflare's bot checks show up as challenge pages or as errors in the 1000 range, such as 1020 for an access rule; the guides on error 1020 and errors 1006 to 1008 cover those. A 522 is an infrastructure problem on the site's side, and it affects every visitor reaching the same origin, though sometimes only through some Cloudflare data centers.
Typical causes on the site's side
- The origin server is down, overloaded or rebooting.
- The origin's firewall blocks or rate limits Cloudflare's IP ranges.
- Wrong DNS: the origin IP in Cloudflare's settings is outdated.
- Network trouble between the Cloudflare data center and the origin's host.
- KeepAlive disabled on the origin, causing connection churn under load.
As a scraper operator you cannot fix any of these. If you own the site, Cloudflare's documentation lists the checks to run; check the current version there.
How a scraper should react
Treat 522 as a temporary server error. Back off and retry after a pause measured in tens of seconds, not milliseconds, and cap the retries. If many URLs on the same domain return 522, pause the whole domain for a while instead of retrying each URL separately. Your traffic should never make an origin's trouble worse.
import collections, time
cooldown_until = collections.defaultdict(float)
def note_origin_error(domain, status):
if status in (520, 521, 522, 523, 524):
cooldown_until[domain] = time.time() + 300 # rest the domain for five minutes
def domain_ready(domain):
return time.time() >= cooldown_until[domain]
When it seems to hit only you
Sometimes a 522 appears through one proxy but not through another, or only from one region. Cloudflare routes you to a nearby data center; if that data center has trouble reaching the origin, users near it see 522 while others do not. Rotating to an exit IP in a different region can help briefly. It does not mean your IP is blocked.
Rarely, an origin's own firewall rate limits connections in a way that surfaces as 522 under very heavy traffic from many Cloudflare nodes. If your scraper is the main source of load on a small site, slowing down is the fix.
522 versus nearby codes
| Code | What timed out or failed |
|---|---|
| 520 | Origin returned an empty or unexpected reply |
| 521 | Origin refused the connection |
| 522 | Connection to the origin timed out |
| 524 | Connected, but the origin did not reply in time; see error 524 |
CAPTCHA tasks and 522
A challenge task needs the target page to load. If the site returns 522, there is no challenge to pass, and a Cloudflare Challenge or Cloudflare Turnstile task against it fails; failed tasks are not charged. Wait until the site responds normally, then solve. Detecting 522 before creating tasks avoids wasting time on attempts that cannot succeed. More on Cloudflare's markers is in identifying Cloudflare protection, and general status codes are covered under HTTP status codes.
Common questions
Does error 522 mean my IP is blocked?
No. It means Cloudflare could not connect to the site's server; blocks look like challenge pages or 1000-range errors.
How long does a 522 last?
Anything from seconds to hours, depending on what broke at the origin, so pause the domain and try again after a few minutes.
Can I solve a 522 with a CAPTCHA task?
No. There is no challenge to pass; the site itself is unreachable through Cloudflare.
Why do I see 522 through one proxy but not another?
Different exit IPs reach different Cloudflare data centers, and only some may have trouble reaching the origin.
What is the difference between 522 and 524?
522 is a failed connection to the origin; 524 is a connection that opened but got no reply in time.
Keep reading
- What is Cloudflare error 524?Error 524 means the origin accepted Cloudflare's connection but sent no HTTP reply before the timeout, usually a slow request.
- Tell Turnstile, managed challenges and blocks apartStatus codes, headers, page markers and cookies that separate a Turnstile widget, a challenge page and a hard Cloudflare block.
- Reverse proxyA reverse proxy fronts a website, so CDN and firewall layers, not site code, usually serve the challenge you meet.
- How do I deal with 504 Gateway Timeout?A 504 means a gateway waited too long for the server behind it; retry later, lighten requests and check slow proxies.