Cloudflare Error 522: Connection Timed Out — What It Means and How to Fix It
A Cloudflare 522 error means Cloudflare tried to open a connection to your origin server and never got a response in time, so it gave up and showed this page to your visitor instead. It's not a Cloudflare outage — it's Cloudflare telling you it couldn't reach your server, or your server took too long to answer.
This is different from a timeout that happens after Cloudflare connects but your server is slow to send data back (that's a 524). A 522 happens earlier: the TCP connection itself either failed outright or wasn't established within Cloudflare's connection timeout window.
What causes a 522
A few things typically cause this, roughly in order of how often they show up:
- The origin server is down or unresponsive. The web server process crashed, the host rebooted, or the machine is out of resources (CPU, memory, or open connections maxed out) and can't accept new connections.
- A firewall is blocking Cloudflare's IP ranges. If your server firewall, security group, or hosting provider's network rules don't allow traffic from Cloudflare's published IP ranges, the connection attempt just hangs until it times out.
- Network routing problems between Cloudflare and your origin. Sometimes the issue isn't your server or Cloudflare individually, but the path between them — a routing issue at your hosting provider or an upstream network.
- The web server is overloaded and not accepting new connections fast enough. This looks similar to "server is down" from Cloudflare's side, but the server is technically up — it's just too busy to respond before the timeout.
- Incorrect DNS or origin configuration. If the DNS record behind the Cloudflare-proxied hostname points to the wrong IP, or an old IP that no longer serves traffic, connections will fail or hang.
How to fix it
1. Check whether your origin server is actually reachable
Before touching Cloudflare settings, confirm the server itself is up. First, use WebWatch's website down checker to confirm the error is happening for everyone, not just on your own connection or ISP. Then test your origin directly, bypassing Cloudflare, by sending the request straight to your server's IP address: curl -I --resolve example.com:443:203.0.113.10 https://example.com/ (replace the domain and IP with your own). If that direct request hangs or fails, the problem is on your server or its network. If it works, look at the path between Cloudflare and your origin.
2. Check your server's resource usage and logs
If the server is reachable but slow to respond, check CPU, memory, and active connection counts. A web server pinned at 100% CPU or out of worker processes/threads will accept the TCP connection late or not at all. Restarting an overloaded web server process (nginx, Apache, PHP-FPM, etc.) is sometimes enough to clear a 522 that started after a traffic spike.
3. Confirm your firewall allows Cloudflare's IP ranges
If you run a firewall on the origin server or through your hosting provider's network/security group settings, make sure inbound traffic from Cloudflare's IP ranges is allowed on the ports Cloudflare connects on (typically 80 and 443). Cloudflare publishes its current IP ranges, and these can change over time, so if your firewall rules are old or were set up manually, re-check them against the current list rather than assuming they're still correct.
4. Verify your DNS record points to the right origin
In your Cloudflare DNS settings, confirm the proxied (orange-cloud) A or CNAME record for the affected hostname points to your current server IP. If you've migrated hosts, resized a server, or changed providers recently, a stale DNS entry pointing at an old IP will produce exactly this error.
5. Check with your hosting provider
If the server looks healthy, the firewall looks fine, and DNS is correct, the problem may be network-level between your host and Cloudflare. Your hosting provider's status page or support team can tell you if there's a known routing or network issue on their end.
522 vs. other 5xx errors
Cloudflare has several similar-looking error codes that mean different things — 521, 523, and 524 are related but distinct from 522, and mixing them up can send you down the wrong troubleshooting path. See our guide to 5xx server errors for how to tell them apart.
Keeping ahead of it
A 522 that only lasts a few seconds is easy to miss if you're not watching for it, but one that lasts minutes or hours means real visitors are hitting an error page. Monitoring your site from the outside — the way a visitor or Cloudflare would see it — means you find out within minutes instead of waiting for a customer to tell you.