Error code 522 (Cloudflare 522) means Cloudflare tried to connect to the website's origin server and got no reply in time. Visitors cannot fix it and can only wait and retry. Site owners should start with the origin firewall, because blocked or rate-limited Cloudflare IPs are the most common cause Cloudflare lists, then check the server itself and the origin IP in DNS.
The error page shows "Connection timed out" and three boxes: your browser, the Cloudflare data center, and the host. Cloudflare is working, and your browser is working. The origin server, or something in front of it, did not answer.
Cloudflare documents two timeouts that produce 522:
- Cloudflare sends a TCP SYN to the origin and gets no SYN+ACK within 19 seconds.
- The TCP connection opens, but the origin does not acknowledge Cloudflare's request within 90 seconds.
In most cases the origin firewall drops Cloudflare's traffic, the server is overloaded or offline, or the DNS record points to the wrong IP address.

Error 522 quick fix: visitor or site owner?
If you are visiting the site
When the host box on the 522 page says "Error" and the other two say "Working", the problem is on the website's server. Nothing on your device causes it.
- Wait a few minutes and reload. Short traffic spikes and server restarts often clear by themselves.
- Try another page on the same site. If nothing loads, the whole origin is down.
- Check Cloudflare's status page if many unrelated sites show 522 at the same time. That pattern is rare, but it is the one case where the cause is on Cloudflare's side.
- If it lasts, tell the site owner the URL, the time, and the Ray ID at the bottom of the page.
Clearing your cache, changing DNS, or turning a VPN on or off does not fix a real 522. If you see the Cloudflare-branded 522 page, your request already reached Cloudflare. A broken DNS setting on your device would give you a browser error, not a Cloudflare page.
If you own the site
Check these in order. The first three cover most 522 errors.
- Does the origin firewall allow all of Cloudflare's IP ranges on ports 80 and 443?
- Is the origin server online, and is the web server running?
- Does the A or AAAA record in Cloudflare DNS point to the current origin IP?
- Is the origin overloaded or out of connection slots?
- Are keepalives enabled on the web server?
What does error 522 mean?
Error 522 is a timeout between Cloudflare and your origin. The request path is:
- A visitor requests your site.
- Cloudflare receives the request at its nearest data center.
- Cloudflare opens a TCP connection to the origin IP in your DNS settings.
- The origin does not answer the SYN within 19 seconds, or does not acknowledge the request within 90 seconds.
- Cloudflare returns error 522.
Cloudflare's connection limits reference lists the exact values. As of October 2026 they are:
| Limit (Cloudflare to origin) | Value | Error at the limit |
|---|---|---|
| Complete TCP connection | 19 seconds | 522 |
| TCP ACK timeout | 90 seconds | 522 |
| Proxy read timeout | 125 seconds | 524 |
Cloudflare lists both 522 limits as not configurable. During the 19-second window, Cloudflare retries the SYN at intervals of 1, 1, 1, 1, 1, 2, 4, and 8 seconds. So a 522 is not one lost packet. The origin ignored about eight connection attempts in a row.
A timeout usually means packets were dropped somewhere. If the origin actively refused the connection, Cloudflare shows error 521 instead. A firewall that silently drops traffic gives 522. A stopped web server on a reachable host gives 521.
Which 52x error do I have?
The four origin errors fail at different points. A direct test against the origin IP (step 1 below) usually tells you which one you are dealing with.
| Error | What happened | What a direct test from outside shows |
|---|---|---|
| 520 | Connected, but the response was empty or invalid | Empty reply, reset, or oversized headers |
| 521 | The origin refused the connection | "Connection refused" right away |
| 522 | The origin did not answer in time | The connection hangs, then times out |
| 523 | Cloudflare has no working route to the origin IP | The DNS IP is wrong or has no working route |
A 524 is different again. The connection works, but the application takes more than 125 seconds to send a response. If the origin's certificate is the problem, you will see error 525 instead.
How to fix error 522 as a site owner
1. Test the origin directly
Bypass Cloudflare and connect to the origin IP. Run this from a machine outside the server's own network:
curl -v --connect-timeout 20 --resolve example.com:443:203.0.113.10 https://example.com/
Replace example.com with your hostname and 203.0.113.10 with your origin IP. For a site on port 80, use --resolve example.com:80:203.0.113.10 http://example.com/.
- It hangs and times out. The origin is down, overloaded, or a firewall drops all traffic. Fix the server first.
- It works fast. The server is fine for you but not for Cloudflare. That usually means a firewall or security tool blocks Cloudflare's IPs.
To check only the TCP handshake, use netcat. A 522 origin hangs here. A 521 origin fails at once with "Connection refused".
nc -vz -w 20 203.0.113.10 443
On the server, confirm the web server listens on the expected ports:
sudo ss -tlnp | grep -E ':(80|443)\s'
2. Watch for Cloudflare's SYN packets on the origin
This test shows where the packets die. Run it on the origin while you load the site through Cloudflare:
sudo tcpdump -ni any 'tcp port 443 and tcp[tcpflags] & tcp-syn != 0'
The filter prints SYN packets from Cloudflare and the SYN-ACK replies from your server. Read it like this:
- No SYNs arrive. Something upstream drops them. Check the cloud firewall, security group, or host DDoS filter.
- SYNs arrive, no SYN-ACK goes out. The server's own firewall drops them, or the listen queue is full (see step 6).
- SYNs and SYN-ACKs both appear. The handshake works. Look at the 90-second ACK timeout, server load, and keepalive.
Use tcp port 80 if your SSL/TLS mode is Flexible.
3. Allow all Cloudflare IP ranges
Cloudflare names this as the most common cause of 522. Every request to your origin comes from a Cloudflare IP, so a firewall or rate limiter that blocks or throttles those IPs blocks your visitors.
Cloudflare publishes its ranges at https://www.cloudflare.com/ips-v4 and https://www.cloudflare.com/ips-v6. To allow them with UFW:
for ip in $(curl -s https://www.cloudflare.com/ips-v4) $(curl -s https://www.cloudflare.com/ips-v6); do
sudo ufw allow proto tcp from "$ip" to any port 80,443
done
With iptables (IPv4 shown, repeat with ip6tables for IPv6, then save the rules so they survive a reboot):
for ip in $(curl -s https://www.cloudflare.com/ips-v4); do
sudo iptables -I INPUT -p tcp -m multiport --dports 80,443 -s "$ip" -j ACCEPT
done
Also check the layers that are not on the server itself:
- Cloud firewalls such as AWS security groups, Google Cloud firewall rules, or Oracle Cloud security lists.
- Hosting panel firewalls such as CSF in cPanel. Add the Cloudflare ranges to the allow list.
- Fail2ban, ModSecurity, Wordfence, and host-level DDoS protection. Search their logs for Cloudflare IPs.
Security tools often ban Cloudflare IPs because every visitor appears to come from a few Cloudflare addresses. Restore real visitor IPs on the origin with mod_remoteip for Apache or ngx_http_realip_module for Nginx, using the CF-Connecting-IP header. Then rate limits and bans apply to real visitors instead of to Cloudflare.
Country blocking on the origin causes the same problem. The origin sees the Cloudflare data center's IP, not the visitor's. Cloudflare's docs recommend a WAF custom rule for geographic restrictions, so the block happens at Cloudflare with the real visitor country.
4. Check the DNS record
In the Cloudflare dashboard, open DNS > Records and compare each proxied A and AAAA record with the real origin IP. After a host migration, an old IP often stays in Cloudflare DNS and every request times out.
Check AAAA records too. If an AAAA record points to an IPv6 address the server no longer uses, Cloudflare can try that address and time out. Delete IPv6 records that do not work.
Public DNS lookups like dig example.com return Cloudflare's IPs, not your origin, so check the dashboard.
5. Match the port to your SSL/TLS mode
Cloudflare's SSL/TLS mode decides which origin port it uses:
| SSL/TLS mode | Cloudflare connects to the origin on |
|---|---|
| Flexible | Port 80 (HTTP) |
| Full or Full (strict) | Port 443 (HTTPS) |
If the mode is Full but a firewall silently drops traffic to port 443, Cloudflare times out with 522. If the port is open but nothing listens there, the server refuses the connection and you get 521 instead. Open port 443 and install a certificate, or use the mode that matches what the origin serves. Also check Rules > Origin Rules for a destination port override that sends traffic to a closed port.
6. Fix origin overload
An origin with no free connection slots stops answering new TCP connections, and Cloudflare reports 522. Look at the error window, not at the current state:
- CPU, memory, and disk I/O on the host.
- Web server limits such as Apache
MaxRequestWorkersor Nginxworker_connections. Apache logs "server reached MaxRequestWorkers setting" when it runs out. - PHP-FPM
pm.max_children, and database connection limits. - Connection states with
ss -sduring a spike.
A full listen queue is a common hidden cause. For a listening socket, ss -lnt shows the current accept queue in Recv-Q and the maximum in Send-Q. If Recv-Q sits at the maximum, the kernel drops new SYNs, which is exactly what Cloudflare sees as a 522. The counters below rise when that happens:
ss -lnt '( sport = :443 )'
nstat -az TcpExtListenOverflows TcpExtListenDrops
Raising timeouts does not fix overload. Cache more pages at Cloudflare, fix slow database queries, add capacity, or move heavy jobs out of the request path.
7. Enable keepalive
Cloudflare lists disabled keepalives at the origin as a cause of 522. Cloudflare reuses open connections to your origin for up to 900 seconds after the last request. An origin that closes every connection forces a new TCP handshake for each request, and under load those handshakes start to time out.
- Apache:
KeepAlive Onis the default, butKeepAliveTimeoutdefaults to 5 seconds in Apache 2.4. Raise it if the server has the memory. - Nginx: keep
keepalive_timeoutabove zero (the default is 75 seconds). A value of0disables keepalive.
8. Home servers and self-hosting
For servers at home (Unraid, Portainer, Home Assistant, a NAS), 522 often means the internet cannot reach your router at all:
- Your ISP blocks inbound ports 80 and 443.
- You are behind CGNAT, so your public IP is shared and port forwarding does not work.
- The router does not forward 80 and 443 to the server, or your home IP changed and DNS still has the old one.
Cloudflare Tunnel avoids all three because the server makes an outbound connection to Cloudflare. If you move to a tunnel and then see a different error, our error 1033 guide covers tunnel connector problems.
9. Find the pattern in Origin Analytics
Cloudflare's Origin Analytics shows the status your origin returned next to the status Cloudflare served. A failed TCP connection shows up as origin status 0 with edge status 522.
Open the Top endpoints table and sort by TCP failure rate. If only a few paths fail, the problem is path-specific, such as one slow route or one upstream that hangs. If every path fails, it is the server, the firewall, or the network.
10. Collect evidence for your host
If the server is fine and Cloudflare IPs are allowed, the problem may be routing between Cloudflare and your host. Collect:
- The Ray ID and the exact time of the error, with the timezone.
- The output of the direct
curlandtcpdumptests. - An MTR or traceroute from the origin to a Cloudflare IP that connected to the origin before the problem started. You can find one in your access logs. For example,
mtr -rwc 50 <cloudflare-ip>. - Firewall logs for the error window.
Send this to your hosting provider. Cloudflare support asks for the same data.
When error 522 is not your origin server
Most 522s are the origin's fault, but Cloudflare's docs list a few cases where the server is fine and the configuration in Cloudflare is wrong.
- A Worker fetches its own hostname. A Worker on a Custom Domain that calls
fetch()on that same hostname gets a 522. Route the Worker on a different hostname, or enable theglobal_fetch_strictly_publiccompatibility flag. - Cloudflare Pages with a bad CNAME. Confirm the custom domain is set up in Pages and the CNAME points to your Pages domain.
- An Origin Rule points at a reserved address. If the rule's target hostname resolves to an address such as
192.0.2.0or100::, Cloudflare cannot connect and returns 522.
The other case is the network between Cloudflare and your host. If the direct test works from several outside locations and the tcpdump test shows no SYNs from some Cloudflare ranges, send the MTR output to your host. Only they can fix routing on their upstream.
Should you pause Cloudflare or switch to DNS only?
Setting the record to DNS only (grey cloud) sends visitors straight to the origin. It is a useful test. If the site loads for everyone while DNS only, the origin accepts the public internet but not Cloudflare, and you are back at step 3.
Treat it as a short test, not a fix. DNS only publishes your origin IP in public DNS, turns off Cloudflare's caching and WAF for that record, and fails completely if your firewall only allows Cloudflare ranges. Switch the record back to proxied once you know the answer.
For the outage itself, Always Online can serve archived copies of your popular pages while Cloudflare cannot reach the origin. It covers only pages the Internet Archive has crawled, and it cannot serve carts, logins, or other dynamic pages.
Error 522 for scrapers, monitors, and retail bots
A different visitor IP does not fix a 522. The failure sits between Cloudflare and the origin, and your proxy or VPN is not on that path.
On retail and ticketing sites, 522 spikes often line up with product drops and on-sales, when the origin runs out of connection slots. Retrying the same URL in a tight loop adds load to a server that is already failing. Back off, cap concurrent requests per site, and log 522 apart from access blocks so your block rate stays honest. Our price monitoring pipeline guide covers retry and backoff design.
If you see Cloudflare's rate-limit page instead, that is error 1015, and request pacing and IP choice do matter there. An origin 429 is covered in our HTTP 429 guide.
How to prevent error 522
- Keep Cloudflare's IP ranges in every firewall layer, and update them when Cloudflare changes the list.
- Restore real visitor IPs on the origin so security tools never ban Cloudflare.
- Monitor the origin from outside its network, not only from inside.
- Set web server and PHP worker limits that match the server's memory, and alert on listen queue overflows.
- Cache static and anonymous pages at Cloudflare to reduce origin load.
- Update DNS records as part of every server migration.
FAQ
What does error code 522 mean?
It means Cloudflare could not finish a connection to the website's origin server before its timeout. Cloudflare waits 19 seconds for the TCP handshake and 90 seconds for the origin to acknowledge the request.
How long does error 522 last?
It lasts until the cause goes away. A traffic spike or a server restart can clear in minutes. A firewall rule that blocks Cloudflare, or a wrong origin IP in DNS, lasts until the site owner fixes it.
Can I increase Cloudflare's timeout to fix error 522?
No. Cloudflare lists the 19-second connection timeout and the 90-second ACK timeout as not configurable. The longer timeout that Enterprise zones can raise is the proxy read timeout, which controls error 524.
Does error 522 hurt SEO?
A short outage rarely matters. Google's crawler documentation says 5xx errors make Google slow down crawling, and URLs that keep returning a server error are eventually dropped from the index. Fix long or repeated 522s quickly.
Can a DDoS attack cause error 522?
Yes. An attack that overloads the origin, or a host DDoS filter that starts dropping Cloudflare traffic, produces 522. Allow only Cloudflare IP ranges on ports 80 and 443 so attackers who find your origin IP cannot reach it directly.
What is the difference between error 522 and 524?
With 522, Cloudflare could not complete the connection to the origin. With 524, the connection opened, but the origin took longer than 125 seconds to send an HTTP response.
Why do only some visitors get error 522?
Different visitors reach different Cloudflare data centers, which use different IPs and network routes to your origin. If your firewall blocks some Cloudflare ranges, or one route is unstable, only some visitors see 522.
Final thoughts
Error code 522 is a connection that never finished. Test the origin directly, then use tcpdump to see whether Cloudflare's SYNs arrive and get an answer. That one test tells you whether to look at the firewall, the listen queue, or the network upstream. Fix the layer it points to, keep every Cloudflare range allowed, and alert on the origin from outside its own network so the next 522 shows up in your monitoring before your visitors report it.
Technical reference: Cloudflare error 522 documentation. For how Google handles server errors, see Google's HTTP status code documentation.