Why does Cloudflare 522 happen intermittently?
Intermittent 522s are usually caused by origin resource exhaustion (CPU/RAM/PHP-FPM workers maxed out), packet loss between edge and origin, or rate-limiting firewalls dropping bursts.
Cloudflare Error 522 occurs when Cloudflare attempts to open a TCP connection to your origin server and receives no ACK before the 15-second handshake timeout (or 90-second read timeout).
# 1. Confirm Cloudflare DNS A record matches your live server IP
# 2. Ensure Nginx keepalive is enabled for Cloudflare edge reuse:
http {
keepalive_timeout 65;
keepalive_requests 1000;
}
# 3. Verify AWS Security Group / Firewall allows inbound TCP 443 from Cloudflare IPs.
curl -v --connect-timeout 10 --resolve example.com:443:ORIGIN_IP https://example.com/
Intermittent 522s are usually caused by origin resource exhaustion (CPU/RAM/PHP-FPM workers maxed out), packet loss between edge and origin, or rate-limiting firewalls dropping bursts.
Yes. Disabling HTTP keep-alive forces a fresh TCP/TLS handshake on every request and significantly increases 522 timeout risk.
Add inbound rules for TCP 443 (and 80 if needed) from Cloudflare's official IPv4/IPv6 CIDR list in your EC2 Security Group and verify Network ACLs allow ephemeral return ports.