Cloudflare Error 522 (Connection Timed Out): Causes and a Tested Fix
Error 522 (Connection timed out) means Cloudflare tried to open a connection to your web server and got no answer in time. Cloudflare itself is fine, and so is the visitor’s browser. The problem sits between Cloudflare and your server, and in most cases it is a firewall or security tool that silently drops Cloudflare’s traffic, or a server too busy or too broken to answer.
If you are only visiting a site that shows error 522, there is nothing to fix on your side: wait a few minutes and try again. If it is your site, the fix is on your server. Below I show exactly how I caused error 522 on purpose on an Nginx server behind Cloudflare, how long each request waited before it failed, how the same firewall rule produced error 521 instead with one small change, and the commands I use to find and fix the cause.
Tested by Dolon Bepari, 20 November 2026
- Server: a throwaway Ubuntu 22.04 VPS (1 vCPU, about 2 GB RAM), aaPanel 7, Nginx 1.30.7, PHP 8.4, WordPress
- Cloudflare: Free plan, orange cloud (proxied), SSL/TLS mode Full (strict), test domain filecafe.site
- How I measured: curl and a browser from my PC in Dhaka, Bangladesh, through Cloudflare, plus commands on the server itself
- There are no affiliate links in this guide. How I test: how we review
Table of Contents
What error 522 means
Error 522 is a Cloudflare status code: Cloudflare could not finish connecting to your origin server (the real server behind Cloudflare). According to Cloudflare’s own error 522 page, it happens in two cases: Cloudflare sends the first packet of a TCP connection (TCP is the basic connection every web request rides on), called SYN, and gets no reply (SYN+ACK) within 19 seconds, or the TCP connection opens but nothing comes back above TCP, such as the TLS handshake, within 90 seconds.
In plain words: Cloudflare knocked, and nobody opened the door. That is different from error 521, where the server slams the door (refuses the connection), and error 524, where the door opens but the server takes too long to finish the page.

The page always shows three boxes. When the last one, Host, is red, Cloudflare is telling you the problem is your server or something in front of it, not Cloudflare and not the visitor.
Is error 522 your fault? Visitor vs site owner
If you are a visitor, no. Error 522 is caused by the website’s server, so clearing your cache, restarting your router or switching browsers will not fix it. Searches like “error 522 Roblox” or “Blooket error 522” are the same story: the service’s own server is not answering Cloudflare. Wait a few minutes, then reload. If it lasts for hours, check the site’s status page or social accounts, or let the owner know.
If you own the site, it is almost always on your side. Cloudflare’s documentation lists firewalls and rate limits that block Cloudflare’s IP addresses as the most common cause. The steps below show how to find it.
How I reproduced error 522 (and what I measured)
Most guides describe error 522 without ever making it happen. I wanted to see the real behaviour, so I set up a fresh test server and broke it on purpose. The server was a throwaway VPS that I deleted afterwards, with a WordPress site on a test domain proxied through Cloudflare’s Free plan.

To recreate the most common cause, I added firewall rules that silently drop (DROP) packets on port 443 that come from Cloudflare’s IPv4 ranges, and only those. The list came from Cloudflare’s published IP ranges and gave 15 rules. Everyone else could still reach the server, which matters for testing later.

Then I requested a small test file through Cloudflare three times from my PC. All three failed with 522, and they waited 19.39, 19.75 and 19.61 seconds before Cloudflare gave up, about 19.6 seconds on average. That matches the 19-second connection timeout in Cloudflare’s documentation. If your 522 shows up only after roughly 19 to 20 seconds, you are looking at this exact situation: packets going in, nothing coming back.

At the same time, the server itself was perfectly healthy. A request made on the server to its own Nginx returned 200, and the firewall counters showed where Cloudflare’s traffic went: the rule for the 172.64.0.0/13 range had caught 55 packets (3,376 bytes), while the other ranges stayed at zero. Only the Cloudflare range my requests came through was hitting the server, so a counter that keeps going up on a Cloudflare range points straight at the firewall.

This is also why so many people report “error 522 when proxied, no problem when DNS only”. With the grey cloud, visitors connect straight to your server and your firewall lets them in. With the orange cloud, every request comes from Cloudflare’s IP addresses, and those are the ones being dropped.
522 vs 521 vs 524: the timing tells you what broke
Next I kept everything the same and changed one word in the firewall rule: REJECT (with a TCP reset) instead of DROP. Now the server actively refuses Cloudflare’s connections instead of ignoring them. Cloudflare’s answer changed from 522 to 521, and it came back in 0.23, 0.22 and 0.20 seconds instead of nearly 20. My Cloudflare error 521 guide covers this refused connection and a stopped web server in more detail.

I saw the same fast 521 when I simply stopped Nginx so nothing was listening on ports 80 and 443: 521 in 0.21 to 0.26 seconds. So a quick 521 means “refused” and a slow 522 means “silence”. In another test on the same server, a PHP script that kept running past Cloudflare’s limit gave 524, which took about 125 seconds, because the connection itself had worked.

| Error | What Cloudflare saw | Time in my test | Where to look first |
|---|---|---|---|
| 522 Connection timed out | No reply to its connection attempt (packets dropped) | 19.39 to 19.75 s | Firewall, rate limits, wrong IP in DNS, overloaded server |
| 521 Web server is down | Connection refused (TCP reset) | 0.20 to 0.26 s | Web server stopped, or a firewall REJECT rule |
| 524 A timeout occurred | Connection worked, but no response before Cloudflare’s limit | about 125 s | Slow PHP, database or long-running scripts |
You may also see 504 Gateway Timeout. That one is not a Cloudflare connection error: it comes from a proxy or gateway in your own setup, such as Nginx waiting on PHP or a load balancer waiting on a backend.
If you can time how long the error takes to appear, you already have a good idea which layer to check.
What causes error 522
These are the causes worth checking, roughly in order of how often they show up. I reproduced the first one in the lab; the others come from Cloudflare’s documentation.
- A firewall or security tool drops Cloudflare’s IP addresses. This can be iptables, UFW or nftables rules, a panel firewall, CSF, fail2ban, or your host’s DDoS filter. A rate limit can do the same once Cloudflare’s few IPs send “too many” requests on behalf of all your visitors.
- The port Cloudflare uses is blocked. With SSL mode Flexible, Cloudflare connects to your server on port 80; with Full or Full (strict) it uses port 443. A firewall that silently drops the port your SSL mode needs gives a 522. My Cloudflare settings for WordPress guide explains which SSL mode to use.
- The origin is overloaded or offline. A server that is out of memory, stuck at 100% CPU or simply switched off may not answer new connections at all.
- The DNS record in Cloudflare points to the wrong IP. This often happens after moving to a new server: Cloudflare keeps knocking on the old one. Check the AAAA (IPv6) record too if you have one.
- Keepalive is turned off on the origin. Cloudflare lists this as a cause, because it relies on keepalive connections to your server.
- Packet loss between Cloudflare and your host. A routing or network problem at the data center. This is the one you cannot fix yourself.
- Cloudflare features pointing at nothing. Origin Rules that send traffic to a hostname that does not resolve, a Worker that fetches its own hostname, or a Cloudflare Pages custom domain that is not set up properly.
How to fix error 522, step by step
Every command below says where to run it and what it does. Only the commands marked “changes” modify anything. Replace example.com with your domain.
Step 1: Check that the server answers locally
▶ On the server (SSH terminal):
curl -sk -o /dev/null -w "origin %{http_code}\n" --resolve example.com:443:127.0.0.1 https://example.com/
What it does: asks the web server on this machine for your homepage, skipping DNS and Cloudflare. It changes nothing. If you get 200 (or a 301/302 redirect), the web server works and the problem is between Cloudflare and the server, which usually means a firewall. In my lab this returned 200 while Cloudflare showed 522. If it hangs or fails, fix the web server first: check that Nginx or Apache is running and look at its error log.
Step 2: Make sure Cloudflare has the right IP
▶ On the server (SSH terminal):
curl -4 -s https://icanhazip.com
What it does: prints the server’s public IPv4 address, as the internet sees it. It changes nothing. Compare it with the A record for your domain in Cloudflare (DNS → Records). If they differ, edit the A record to the correct IP. If you have an AAAA record, make sure that IPv6 address really belongs to this server too, or delete it.
Step 3: Look for firewall rules that drop Cloudflare
▶ On the server (SSH terminal):
iptables -L INPUT -n -v --line-numbers | grep -E "DROP|REJECT"
Run these as root, or put sudo in front. The second command also shows the chains that fail2ban, UFW and CSF create:
iptables -S | grep -E "DROP|REJECT|f2b|ufw|csf"
What they do: the first lists the DROP and REJECT rules on incoming traffic, with packet counters and line numbers; the second lists every rule in every chain that mentions a drop, a reject or one of those tools. Neither changes anything. Look for any rule that matches a Cloudflare range (for example 104.16.0.0/13, 172.64.0.0/13 or 173.245.48.0/20) or for a chain from fail2ban or CSF. Run it twice, a minute apart, while the site shows 522: a counter that keeps climbing on a Cloudflare range is your answer, exactly like the 55 packets in my test.
If you use UFW, also run ufw status numbered. If you use aaPanel, check its Security page for blocked IPs and port rules, and any WAF or firewall plugin you installed there.
Step 4: Remove the rule and allow Cloudflare’s ranges
▶ On the server (SSH terminal): (changes the firewall)
iptables -D INPUT 3
What it does: deletes rule number 3 from the INPUT chain. Use the line number you found in step 3. With UFW, use the number shown by ufw status numbered and run ufw delete NUMBER (it asks you to confirm). A deleted iptables rule comes back after a reboot if it was saved with netfilter-persistent, so remove it from the saved rules too. Rules added by fail2ban, CSF or a panel can come back, so also fix them at the source: put Cloudflare’s ranges in fail2ban’s ignoreip or CSF’s csf.allow and csf.ignore.
▶ On the server (SSH terminal): (changes the firewall, UFW only)
for ip in $(curl -sL https://www.cloudflare.com/ips-v4); do ufw insert 1 allow proto tcp from $ip to any port 80,443; done
What it does: downloads Cloudflare’s current IPv4 list and adds an allow rule for ports 80 and 443 for each range, at the top of UFW’s list so an older deny rule cannot win. Run it again with ips-v6 if your server has IPv6. An allow rule does not beat a ban that another tool inserts above it, which is why the whitelist in fail2ban or CSF still matters.
Step 5: Check that the server is not overloaded
▶ On the server (SSH terminal):
uptime; free -m; ss -tln | grep -E ':(80|443) '
What it does: shows the load average, free memory, and whether anything listens on ports 80 and 443. It changes nothing. A load average far above your CPU count or almost no free memory means the server may be too busy to accept new connections. If nothing listens on 80 or 443 you would normally see 521 rather than 522, as in my test. A small server that keeps falling over is a capacity problem, not a Cloudflare problem.
Step 6: Check that keepalive is on
▶ On the server (SSH terminal): (aaPanel path; on a standard Nginx install use just nginx -T)
/www/server/nginx/sbin/nginx -T 2>/dev/null | grep -n keepalive_timeout
What it does: prints the full Nginx configuration and shows the keepalive_timeout lines. It changes nothing. A value of 0 turns keepalive off. No line at all means Nginx uses its default, which keeps keepalive on. On my own aaPanel server it was 60. On Apache, look for KeepAlive On.
Step 7: Still 522? Ask your host, with evidence
If the server answers locally, your firewall is clean and the IP is right, the drop is probably happening before traffic reaches your server, for example in your host’s network firewall or DDoS filter. Send your host the time of the error, the Ray ID (the request ID Cloudflare prints at the bottom of the 522 page) and the output of the commands above. Cloudflare also suggests including an MTR or traceroute (tools that show where packets get lost on the way) from your server to a Cloudflare IP that appears in your logs.
Check that it is fixed
▶ On your own computer, in Windows cmd. On Mac or Linux, use curl instead of curl.exe, /dev/null instead of NUL, and ; instead of & between the three commands:
curl.exe -s -o NUL -w "%{http_code} %{time_total}\n" https://example.com/ & curl.exe -s -o NUL -w "%{http_code} %{time_total}\n" https://example.com/ & curl.exe -s -o NUL -w "%{http_code} %{time_total}\n" https://example.com/
What it does: requests your homepage through Cloudflare three times and prints the status code and total time for each. It changes nothing. In my lab, as soon as I removed the DROP rules the same requests returned 200 in 0.51, 0.62 and 0.22 seconds. I did not purge anything or change any Cloudflare setting; once Cloudflare could connect again, the error was gone.
Fixing error 522 on shared hosting or Apache
On shared hosting you cannot see the firewall, but the same causes apply. Ask your host whether their firewall, ModSecurity rules or DDoS protection are blocking Cloudflare’s IP ranges, and confirm the server IP for your A record. If your host cannot or will not allowlist Cloudflare, that alone is a reason to consider a different plan; I compare the trade-offs in shared hosting vs VPS.
On an Apache server you manage yourself, check .htaccess for Deny from or Require not ip lines that cover Cloudflare ranges, then run steps 3 to 6 above. The firewall commands are the same whatever web server you run.
Does error 522 hurt SEO?
A short 522 is unlikely to cause lasting harm. Google’s documentation says 5xx server errors make Googlebot slow down its crawling of your site, and that already indexed URLs that keep returning server errors are eventually dropped from the index. So fix it the same day, and do not leave a site on error 522 for days.
Visitors are the bigger cost: a page that hangs for almost 20 seconds before showing an error is a very poor experience.
How to prevent error 522
- Keep Cloudflare’s ranges allowed everywhere: OS firewall, panel firewall, fail2ban, CSF and any security plugin that writes firewall rules.
- Make your logs show real visitor IPs. Behind Cloudflare, your logs record Cloudflare’s IP for every visitor unless you restore the original IP. Then fail2ban or a rate limiter can end up banning Cloudflare itself. Cloudflare explains how to restore visitor IPs for Nginx and Apache. I did not test fail2ban in this lab, so treat this as a check, not a measured result.
- Update the DNS record when you move servers, and remove old AAAA records.
- Monitor through Cloudflare, not only the server. An uptime check that loads your real domain catches a 522 that a check on the server’s IP would miss.
- Give the site enough server. If your origin keeps running out of memory, a better VPS fixes the cause. I tested Vultr, Hetzner and DigitalOcean with real numbers.
- Set up Cloudflare sensibly. My Cloudflare settings for WordPress guide covers SSL mode and the rest, and cf-cache-status explained helps you check what Cloudflare is caching once the site is back.
Error 522 FAQ
Is error 522 my fault?
Not if you are a visitor: the website’s server is not answering Cloudflare, and nothing on your device will fix it. If you own the site, the cause is almost always on your server or your host’s network, most often a firewall that blocks Cloudflare’s IP addresses.
How long does error 522 last?
Until Cloudflare can connect to the server again. In my test the site came back on the very next request after I removed the firewall rule. If it is caused by an overloaded server, it lasts as long as the overload does.
Why does my site work on DNS only but show 522 when proxied?
With DNS only (grey cloud), visitors connect to your server directly. With the orange cloud, all traffic comes from Cloudflare’s IP ranges. If your firewall or host blocks those ranges, only the proxied version fails, which is exactly what I reproduced.
What is the difference between error 521 and 522?
521 means the server refused the connection, and it appears fast: 0.20 to 0.26 seconds in my tests. 522 means the connection attempt got no reply at all, so Cloudflare waits about 19 seconds first. The same firewall rule gave 521 with REJECT and 522 with DROP.
Can I increase the 522 timeout in Cloudflare?
Cloudflare’s 522 documentation describes the 19-second wait as part of how the connection attempt works and mentions no setting to change it. Raising it would not help anyway: a server that does not answer in 19 seconds needs fixing, not more time.
Can a DDoS attack cause error 522?
Yes, indirectly. A flood of traffic can overload your server until it stops answering, and some hosts react to an attack by filtering traffic, which can drop Cloudflare’s connections too. Either way Cloudflare sees no reply and shows 522.
Will upgrading my Cloudflare plan fix error 522?
No. The cause is your server, its firewall or your host’s network, not your Cloudflare plan. My test ran on the Free plan, and the error disappeared as soon as the firewall rule was removed.
My host says error 522 is Cloudflare’s fault. What now?
Show them the evidence from the steps above: the server answering locally, the firewall counters, the DNS record and the Ray ID with the time of the error. Ask them to check their network firewall and DDoS filter for blocked Cloudflare ranges.
Can a WordPress plugin cause error 522?
Not directly. WordPress plugins run only after a connection is made, so they cause errors like 403 or 500, not 522. A security plugin can contribute if it adds firewall rules on the server, and a heavy plugin can overload a small server until it stops accepting connections.
