< HTTP/1.1 522 Connection Timed Out522 Connection Timed Out
Cloudflare-specific error when unable to establish a TCP connection to the origin server. Learn how to diagnose and fix 522 timeout errors.
- Cacheable
- No
- Retry?
- Yes, with backoff
- Usually sent by
- Cloudflare edge
TL;DR: Cloudflare could not complete a TCP connection to your origin within 19 seconds, or connected but never acknowledged the request within 90 seconds. Usual causes: a firewall silently dropping Cloudflare IPs, an overloaded origin, or the wrong origin IP in DNS.
What it means
Cloudflare sent a SYN and got nothing back, or the connection opened and the origin then stalled before acknowledging the request. Cloudflare’s connection-limits page documents two clocks: 19 seconds to complete the TCP connection (no SYN+ACK after the SYN), and 90 seconds after the connection is up to receive an ACK for the request. Neither is configurable. Dropped packets (a DROP rule, a security group with no matching allow) cause timeouts; a REJECT causes 521.
Who sent it?
server: cloudflare with a cf-ray header and the “Connection timed out” page. The request never reached your application, so app logs are empty.
Fix it
-
Test reachability from outside your network.
curl -sv --connect-timeout 10 --resolve example.com:443:203.0.113.10 https://example.com/ -o /dev/null mtr -rwc 20 -T -P 443 203.0.113.10A hang at
Trying 203.0.113.10:443...means dropped packets. -
Allowlist Cloudflare ranges from
https://www.cloudflare.com/ips-v4andips-v6in iptables/nftables,ufw, CSF/Fail2ban, hosting-provider firewalls, and AWS/GCP/Azure security groups. Shared hosts often rate-limit these IPs by default. -
Verify the DNS record in Cloudflare points to the current public origin IP. After a server migration or a cloud instance restart without an Elastic IP, the old address will time out.
-
Check origin load. Saturated CPU, exhausted
worker_connections, a full SYN backlog or PHP-FPMpm.max_childrenreached makes the origin stop accepting connections. Look atss -s,dmesg | grep -i syn, andnginx -T | grep worker_connections. -
Look for rate limiting by the host or ISP treating the Cloudflare edge as a flood.
-
Confirm the port and SSL mode. Full or Full (strict) connects to 443; Flexible connects to 80.
-
Long-running requests after the connection opens belong to 524, which runs a separate clock (125 seconds by default).
Verify
curl -sI https://example.com/ | grep -iE 'HTTP|cf-ray'
When the origin is healthy again the status changes from 522 to your app’s normal response with no change on the Cloudflare side.
522 vs 521 vs 523 vs 524
| Code | What happened |
|---|---|
| 521 | Connection refused immediately |
| 522 | Connection or acknowledgement timed out (dropped packets) |
| 523 | Origin IP unreachable (bad DNS, private IP, no route) |
| 524 | Connected, but no HTTP response within 125 seconds (default) |
Related
Frequently asked questions
What does Cloudflare error 522 mean?
A 522 error means Cloudflare could not establish a TCP connection to your origin server within the timeout period. The server exists but is not responding in time.
How do I fix a 522 error?
Check origin server load and performance, verify network connectivity, ensure Cloudflare IPs are whitelisted, check for rate limiting, and verify DNS points to correct IP.
What is the difference between 521 and 522?
521 means the connection was refused (server down or blocking). 522 means the connection attempt timed out (server slow or network issues). Both indicate origin connectivity problems.
What causes 522 timeout errors?
Common causes include server overload, network congestion, firewall silently dropping packets, incorrect origin IP in Cloudflare, or ISP routing issues.
Sources
Related
524 A Timeout Occurred
Cloudflare-specific error when the origin server takes too long to respond. Learn how to diagnose and fix 524 timeout errors.
520 Web Server Returned an Unknown Error
Cloudflare-specific error when the origin server returns an unexpected response. Learn about 520 errors and how to troubleshoot them.
521 Web Server Is Down
Cloudflare-specific status code indicating the origin server refused the connection. Learn about this proxy error and how to troubleshoot it.
523 Origin Is Unreachable
Cloudflare-specific error when the origin server's IP address is unreachable. Learn about DNS and routing issues causing 523 errors.