← Back to all articles

Error Code 522: Cloudflare Connection Timed Out Fix

by Unknown Proxies

14 min read

Updated October 17, 2026

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:

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.

Diagram showing Cloudflare timing out while trying to connect to an origin server

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.

  1. Wait a few minutes and reload. Short traffic spikes and server restarts often clear by themselves.
  2. Try another page on the same site. If nothing loads, the whole origin is down.
  3. 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.
  4. 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.

  1. Does the origin firewall allow all of Cloudflare's IP ranges on ports 80 and 443?
  2. Is the origin server online, and is the web server running?
  3. Does the A or AAAA record in Cloudflare DNS point to the current origin IP?
  4. Is the origin overloaded or out of connection slots?
  5. 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:

  1. A visitor requests your site.
  2. Cloudflare receives the request at its nearest data center.
  3. Cloudflare opens a TCP connection to the origin IP in your DNS settings.
  4. The origin does not answer the SYN within 19 seconds, or does not acknowledge the request within 90 seconds.
  5. 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/.

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:

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:

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:

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.

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:

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:

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.

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

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.

Need clean IPs for this setup?

Static ISP proxies for steady sessions and rotating residential pools when you need fresh exits, backed by a live site list and support on Discord.

View pricing