Skip to content

HTTP 522 from Cloudflare to a cPanel origin: where the path breaks

A 522 means Cloudflare could not connect to your cPanel server in time. The fix lives in the firewall, the listener, or the path between Cloudflare and the origin.

A 522 Connection Timed Out from Cloudflare means Cloudflare’s edge tried to open a TCP connection to your cPanel origin, waited around 15 seconds, and gave up. The cause is at the network layer (a firewall blocking Cloudflare IPs), the listener layer (Apache or LiteSpeed not bound), or the host layer (the box is overloaded and not accepting new connections). The fix path is from the edge backwards.

What’s happening

Cloudflare’s edge connects to the origin IP on port 80 or 443. If the TCP handshake does not complete within ~15 seconds, Cloudflare returns 522 to the user. Common causes are CSF or iptables blocking the Cloudflare edge ranges, Apache being stopped, the origin IP being wrong in the Cloudflare DNS panel, or the host being slammed (high load average, can’t accept new sockets). cPanel does not log 522 — Cloudflare does, but the underlying TCP timeout is visible from the origin.

How to verify

From outside the cPanel host (so not via Cloudflare):

# is the origin reachable on the expected ports?
nc -zv <origin-ip> 80
nc -zv <origin-ip> 443
# does the origin answer HTTPS with the right cert?
curl -ILk --resolve example.com:443:<origin-ip> https://example.com

On the cPanel host:

# is Apache or LiteSpeed listening?
ss -lnp | grep -E ":(80|443) "
# is CSF blocking the Cloudflare ranges?
csf -g 173.245.48.0/20    # one of Cloudflare's ranges
# is the box overloaded?
uptime ; ss -s
# DNS — what IP does Cloudflare resolve the origin to?
dig +short example.com @1.1.1.1

The fix

  1. CSF must allow Cloudflare — the up-to-date IPv4 and IPv6 ranges live at https://www.cloudflare.com/ips/. Add to /etc/csf/csf.allow (or use the Cloudflare CSF plugin), restart CSF.
  2. Apache or LiteSpeed restart — systemctl status httpd or /usr/local/lsws/bin/lswsctrl status. If down, start it. If running but not accepting connections, ss -lnp will show no listener — restart.
  3. Origin IP mismatch — in Cloudflare DNS, the A record should point at the cPanel host’s public IP, not an internal LAN address. If a private IP is listed, Cloudflare cannot reach it.
  4. Host overload — uptime showing load > number of cores, with TCP accept queue full (ss -s shows synrecv > 0), means the box is dropping connections. Find the load source: top, iotop, htop.
  5. MTU or path issue — rare, but a downstream firewall stripping ICMP and breaking PMTU discovery can cause silent timeouts to large packets. Test with mtr <cloudflare-edge-ip>.

If 522s only hit at peak hours, the box is undersized for the workload — Stack Harbor handles capacity reviews and Cloudflare-origin tuning under managed cPanel operations — start a conversation when 522s correlate with load.