About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.
Cloudflare Error 522 means Cloudflare timed out contacting the origin web server: the TCP handshake never completed, or no data above TCP arrived in time after connect. Fix blocked Cloudflare IPs, an offline or overloaded origin, or a stale DNS target. This is not Error 524, where the origin connected then took too long to finish an HTTP response.
What the symptom means
Cloudflare titles the fault "Error 522: connection timed out" and states: "Error 522 occurs when Cloudflare times out contacting the origin web server."
Two timeouts cause HTTP error 522:
- "Before a TCP connection is established, Cloudflare does not receive a SYN+ACK within 19 seconds after sending a SYN. The SYN retry backoff intervals are 1, 1, 1, 1, 1, 2, 4, and 8 seconds."
- "After the TCP connection is established, Cloudflare does not receive any data above the TCP layer (for example, a Server Hello during TLS negotiation) within 90 seconds."
Error 521 is an active refuse. Error 522 is silence long enough to hit those timers.
Likely causes
| Cause | What you see | How to confirm |
|---|---|---|
| Cloudflare IPs rate limited or blocked | 522 after firewall, .htaccess or iptables changes |
Compare blocked sources with Cloudflare IP ranges |
| Overloaded or offline origin | 522 under load; host CPU, backlog or process down | Origin metrics and process list at the cf-ray time |
| Keepalives disabled at the origin | Intermittent 522 with otherwise healthy hosts | Review origin keepalive settings with the host |
| DNS A/AAAA target wrong | 522 after a server move or IP change | Compare Cloudflare DNS target with the provisioned origin IP |
| Packets dropped on the path to the origin | 522 from many edges; traceroute loss toward the origin | MTR or traceroute from origin toward a connecting Cloudflare IP |
AWS VPC route captures 172.64.0.0/13 |
522 from edges that use that egress range | VPC routes covering 172.x.x.x to an internal target |
Prove the cause before changing anything
These steps only read.
-
Note the full URL, time and cf-ray. For support, collect an MTR or traceroute from the origin to a Cloudflare IP that commonly connected before the fault (from origin logs).
-
Confirm the Cloudflare DNS A/AAAA target still matches the provisioned origin IP.
-
Check whether Cloudflare IP addresses are rate limited or blocked in
.htaccess, iptables or other firewalls — allowing all Cloudflare IP ranges is the most common cause to confirm. -
Separate 522 from 524: a slow HTTP answer after connect is Error 524's Proxy Read Timeout, not the 19-second SYN or 90-second first-data timers.
Fix
Allow Cloudflare IP ranges (most common cause)
Cloudflare IP addresses may be "rate limited or blocked in .htaccess, iptables, or firewalls". Replace $ip with each published Cloudflare range.
Save the current packet filter first:
iptables-save > /root/iptables-before-cloudflare-allow.rules
ip6tables-save > /root/ip6tables-before-cloudflare-allow.rules
Risk: the next commands insert ACCEPT rules for Cloudflare source ranges on ports http and https. A typo in $ip leaves 522 in place; a wrong range accepts unintended sources on those ports.
For each Cloudflare IPv4 range:
iptables -I INPUT -p tcp -m multiport --dports http,https -s $ip -j ACCEPT
For each Cloudflare IPv6 range:
ip6tables -I INPUT -p tcp -m multiport --dports http,https -s $ip -j ACCEPT
To undo it: restore the saved rulesets only if you have made no other firewall change since saving (restore replaces the whole rule set):
iptables-restore < /root/iptables-before-cloudflare-allow.rules
ip6tables-restore < /root/ip6tables-before-cloudflare-allow.rules
If the host panel or security group rate-limits Cloudflare sources, record the current rate-limit rules first (screenshot or export the panel shows):
echo "rate_limit_note=<paste or describe the current rule>" > cloudflare-rate-limit-before.txt
Risk: the next step clears or widens a rate limit that targeted Cloudflare sources. While that limit is gone, those sources are no longer throttled by that rule until you put it back.
Clear or adjust the rate limit that targets Cloudflare sources in the host panel or security group. Prefer a Cloudflare WAF custom rule when you need geography limits instead of blocking Cloudflare at the origin.
To undo it: restore the rate-limit rule described in cloudflare-rate-limit-before.txt.
Correct the DNS target or restore the origin
If DNS still points at a decommissioned address, record the current A/AAAA target in the Cloudflare DNS app before you change it:
echo "www.example.com a=<current target>" > cloudflare-dns-target-before.txt
Risk: the next step changes the proxied A/AAAA target. A wrong target keeps the site unreachable through Cloudflare until you set the old target back.
Update the A/AAAA in the Cloudflare DNS app to the provisioned origin IP.
To undo it: set the old target back from cloudflare-dns-target-before.txt.
If the origin is offline or overloaded, restore capacity until SYN+ACK and the first bytes above TCP arrive inside Cloudflare's timers.
As this article's own diagnostic step (the Error 522 page does not give it; Error 520 does), use DNS-only only while you prove direct origin reachability. Save the proxy state first:
echo "www.example.com proxied=yes" > cloudflare-dns-proxy-before.txt
Disruptive step: the next change sets the hostname to DNS-only (grey cloud), so visitor traffic bypasses Cloudflare's proxy and hits the origin IP directly until you reverse it.
In the Cloudflare DNS app, set the failing record to DNS only long enough to test whether the origin answers. If it never answers, the fault is at the origin or on the path.
To undo it: set the record back to Proxied per cloudflare-dns-proxy-before.txt.
Example (illustrative): after a firewall rebuild, origin logs show no handshakes from Cloudflare ranges. Re-adding the published allow rules restores SYN+ACK inside 19 seconds.
Confirm the fix
- Reload the proxied URL; it should not return Error 522.
- Confirm origin logs accept Cloudflare IP ranges again.
- If you used DNS-only, confirm the record is Proxied again.
What to watch afterwards
- Host firewall auto-blocks that treat Cloudflare's shared ranges as a flood.
- Origin IP changes after rebuilds — update the Cloudflare DNS target in the same window.
- AWS VPC routes that capture
172.64.0.0/13.
Read next
Related articles you may want next.
- TroubleshootingCloudflare Error 521: Web server is downCloudflare Error 521: origin refused Cloudflare connections. Check the web server is up, allow Cloudflare IPs, and match port 80 or 443 to your SSL mode.Read article
- TroubleshootingCloudflare Error 524: A timeout occurredCloudflare Error 524: origin connected but missed the 125s Proxy Read Timeout or 30s write timeout. Speed up the origin or grey-cloud long jobs.Read article
- Troubleshootingnginx 504 Gateway Time-out: upstream timed out (110: Connection timed out) while reading response headernginx 504 Gateway Time-out and upstream timed out (110: Connection timed out) while reading response header. Find the slow phase and set timeouts safely.Read article
Risks and limits
These steps have not been lab-tested.
Error 522 uses only the 19-second SYN and 90-second post-connect timers. This is not nginx 504 upstream timed out. Keepalives disabled at the origin are listed as a cause; Cloudflare gives no keepalive interval for that cause.
Sources
- Error 522 — Cloudflare, Last updated Nov 16, 2026, accessed 1 December 2026
- Cloudflare IP addresses — Cloudflare, Last updated Apr 21, 2026, accessed 1 December 2026
This article was originally published on .