Find out why your server never answered Cloudflare

Cloudflare error 522 means Cloudflare gave up waiting on your origin server: the server either never accepted the connection or accepted it and then sent nothing back. Nothing told Cloudflare to go away, as happens with a 521. Its packets simply went unanswered. Cloudflare names blocked Cloudflare addresses as the most common cause, and an overloaded or offline server, or an origin IP address that no longer belongs to your server, does the same.

The two timeouts behind a 522

  • Cloudflare opens a connection by sending a SYN packet. If no SYN+ACK comes back within 19 seconds, after retries spaced 1, 1, 1, 1, 1, 2, 4 and 8 seconds apart, the visitor gets a 522. Either the packets never reached a listening server, or the server's replies never made it back.

  • Once the connection is open, Cloudflare waits up to 90 seconds for anything above the TCP layer, such as the Server Hello your server sends back during a TLS handshake. A server too busy to begin the handshake runs into this second limit. Both numbers come from Cloudflare's error 522 guide.

Why Cloudflare's packets go unanswered

  • A firewall drops Cloudflare's traffic

    An iptables rule or a network firewall silently drops or rate limits some of Cloudflare's addresses, so their connection attempts run out the clock.

  • The server is overloaded or offline

    A server out of capacity stops picking up new connections in time, and one that's switched off never answers at all.

  • The origin IP address is out of date

    After a move to a new server or a new address, the DNS record in Cloudflare still points at the old IP, where nothing answers for your site.

  • Keepalives are turned off

    Cloudflare reuses open connections to your origin and asks you to keep HTTP keep-alive enabled on the server, which helps avoid connection resets.

Cloudflare's error 522 guide lists these causes and calls rate-limited or blocked Cloudflare addresses the most common one. Its connection limits page explains the keep-alive advice.

See whether Cloudflare's packets reach the server

# On the origin server: print each connection attempt on port 443 and the server's SYN+ACK reply
sudo tcpdump -ni any 'tcp port 443 and tcp[tcpflags] & tcp-syn != 0'

# From another machine: open a TCP connection to the origin's IP (203.0.113.10 here), giving up after 19 seconds
nc -vz -w 19 203.0.113.10 443

How to fix Cloudflare error 522

  1. Check that the origin IP is currentCompare the address in the DNS record for the proxied hostname with the public IP your host assigns the server today, and correct the record if the server moved.
  2. Watch for the packets during a 522Run the packet capture while the error is happening. No attempts from Cloudflare's addresses means something upstream drops them; attempts that arrive with no SYN+ACK going back point to the server's own firewall or load.
  3. Let Cloudflare through every firewallYour host may filter traffic in front of the server as well as on it. Make sure both layers pass all of Cloudflare's ranges with no per-IP connection limit.
  4. Take load off the serverIf connections get slow under traffic, check CPU, memory and the web server's connection limits for the same minutes, then add capacity or fix what fills them.
  5. Send a trace to your hostIf none of that helps, run mtr or traceroute from the origin to a Cloudflare address found in your access logs and send the output to your host with the times of the 522s.

Frequently asked questions

What's the difference between error 521 and 522?

With a 521, your server actively refused the connection, so nothing is listening or a firewall rejects it. With a 522, nothing answered within Cloudflare's time limits, so packets were dropped or the server was too busy. Cloudflare's guides for 521 and 522 list the causes of each.

Why does a 522 come and go?

Intermittent 522s point to something that depends on traffic. A firewall that limits connections per IP blocks a Cloudflare address only after it sends enough requests, and an overloaded server stops answering only at busy times. Match the times of the 522s against your traffic and the firewall's log.

How do I hear about the next outage?

A 522 shows visitors an error page while your server's own logs can stay quiet, because the dropped packets never reach the web server. SiteCMD requests your home page every few minutes once you add the site, and it emails you when the site goes down and again once it recovers.