Skip to content

Cloudflare 522 connection timed out: find and fix the real cause

Cloudflare error 522 means the edge dialed your origin and got silence — no refusal, no answer. The cause is almost always a firewall dropping Cloudflare's IPs, an overloaded origin, or a wrong IP in DNS. Here is the diagnosis path for any origin.

Cloudflare error 522 means the edge tried to reach your origin and got silence — the TCP handshake never completed. Unlike a 521 (actively refused), nobody answered at all, which almost always means a firewall silently dropping Cloudflare’s IP ranges, an origin too overloaded to accept new connections, or a DNS record pointing at an IP that no longer serves your site. The single highest-yield fix: confirm every firewall layer allows Cloudflare’s published IP ranges with an ACCEPT, not a DROP.

What’s happening

For a proxied hostname, the visitor’s browser connects to the Cloudflare edge, and the edge opens its own TCP connection to the origin IP in your DNS record. A 522 fires in two documented situations, per Cloudflare’s HTTP status code reference: the origin never answered Cloudflare’s SYN with a SYN-ACK within about 15 seconds, or the connection was established but the origin then failed to acknowledge the request within about 90 seconds. Either way, the defining symptom is silence — packets went out, nothing came back.

Silence has a different cause profile than refusal. A REJECT firewall rule or a closed port answers immediately (that produces a 521); a DROP rule, a full connection backlog, an exhausted conntrack table, or a black-holed route answers never — and that produces the 522. These timeouts are the same on Free, Pro, and Business plans; they are not configurable settings. If your origin is a cPanel server, the cPanel-specific 522 walkthrough covers that stack’s particular failure points; this guide is the generic path for any origin.

What to check first

  • Does the site load when you bypass Cloudflare? If direct access also hangs, the origin or its network is the problem for everyone, not just Cloudflare.
  • Firewall recently touched? New rules, a fail2ban/CSF ban wave, or a cloud security group change are the most common trigger for sudden 522s.
  • Did the origin IP change? A migration or provider re-IP with a stale record in Cloudflare produces textbook 522s.
  • Is the origin under heavy load? Load average, memory pressure, and connection counts — an origin at its limits stops answering new SYNs before it stops serving established connections.
  • Constant or intermittent? Constant points at a rule or a dead path; intermittent points at load, conntrack exhaustion, or bans on a subset of Cloudflare ranges.

How to verify

From an external machine, dial the origin the way Cloudflare does (origin IP from your DNS → Records screen — public DNS returns edge IPs for proxied names):

# Direct origin test - a hang ending in a timeout mirrors what Cloudflare sees
curl -sv --max-time 20 --resolve example.com:443:203.0.113.10 https://example.com/ -o /dev/null

# Is the host reachable at the network level, and where does the path die?
mtr -rwzbc 20 203.0.113.10

# Raw TCP check on the port
nc -vz -w 10 203.0.113.10 443

On the origin, look for the silent-drop suspects:

# DROP rules that could swallow Cloudflare's ranges
iptables -L INPUT -n --line-numbers | grep -i drop
nft list ruleset | grep -i drop

# Are Cloudflare ranges banned by CSF or fail2ban?
grep -E '173\.245|141\.101|108\.162|162\.158|104\.1[6-9]|172\.6[4-9]|198\.41' /etc/csf/csf.deny 2>/dev/null
fail2ban-client banned 2>/dev/null | head

# Connection-tracking exhaustion silently drops new connections
sysctl net.netfilter.nf_conntrack_count net.netfilter.nf_conntrack_max
dmesg -T | grep -i conntrack | tail

# SYN backlog overflow under load
ss -s
netstat -s | grep -i 'SYNs to LISTEN'

If curl from outside connects instantly while Cloudflare still reports 522, the drop is selective: some networks (Cloudflare’s) are being dropped while yours is not — go straight to the firewall and ban lists.

The fix

  1. Firewall dropping Cloudflare ranges — the top cause. Add explicit allow rules for all published Cloudflare IP ranges (current list at https://www.cloudflare.com/ips/) at every layer that filters: host firewall, CSF/fail2ban, and the provider’s cloud firewall or security groups. Partial allowlists cause intermittent 522s, which are worse to debug than constant ones.
  2. Stale origin IP in DNS — Cloudflare is dialing an IP that silently discards traffic (a reclaimed cloud IP, a decommissioned box behind a firewall). Update the A/AAAA record in DNS → Records to the current origin IP.
  3. Origin out of capacity — load average pinned, SYNs to LISTEN sockets dropped climbing, or the web server at its worker ceiling. Raise net.core.somaxconn and the web server’s backlog/worker limits only after fixing what is consuming the capacity — a runaway cron, a slow database, or an unthrottled crawler.
  4. Conntrack table full — nf_conntrack: table full, dropping packet in dmesg. Raise net.netfilter.nf_conntrack_max and lower established-connection timeouts, then find what is opening that many connections in the first place.
  5. Routing or NAT path broken — mtr dies before reaching the origin from some networks. That is a provider ticket, not a server fix; attach the mtr output from both a working and a failing vantage point.
  6. Structural fix: stop accepting inbound dials entirely — if the origin sits behind NAT, a strict corporate firewall, or a provider that re-IPs frequently, a Cloudflare Tunnel makes the origin dial out to Cloudflare instead, and this entire class of 522 disappears.

When this fix is wrong

If the 522 is intermittent and correlates with traffic peaks, stop hunting firewall rules — you have a capacity problem, and allowlisting ranges that are already allowed changes nothing. Conversely, if direct curl to the origin works from your laptop, do not conclude “the origin is fine”: your IP is not Cloudflare’s, and the whole point of a selective drop is that it treats those differently.

Common mistakes

  • Testing only from your own IP and declaring the origin healthy while Cloudflare’s ranges stay banned.
  • Allowlisting Cloudflare in the host firewall but forgetting the provider’s security group in front of it — the packet dies before the host ever sees it.
  • Pausing Cloudflare or grey-clouding the record as a “fix” — the site works again because visitors now bypass the drop, but the origin IP is exposed and the underlying rule is still wrong.
  • Raising PHP or web server timeouts. A 522 happens before any HTTP request is processed; application timeouts are unrelated (that territory belongs to error 524).

Prevention

  • Automate Cloudflare IP-range sync into every firewall layer, with a scheduled job and an alert if the fetch fails.
  • Restore real visitor IPs at the web server so fail2ban/CSF ban actual offenders instead of the edge.
  • Monitor the origin directly by IP with an external probe, so origin-down and Cloudflare-path-down alarms are distinguishable.
  • Alert on conntrack usage above ~80% and on SYN backlog drops.
  • After migrations, make “update Cloudflare DNS record content” an explicit checklist line, and lower record TTLs before the move, not after.

A 522 is Cloudflare telling you where the silence is, and the diagnosis above finds who is being silent. If the error keeps coming back, the problem usually sits between Cloudflare and the origin — Stack Harbor operates that whole path under Managed Cloud Ops, and you can book an infrastructure review.