Knowledgebase

Find frequently asked questions and setup guides by searching or by browsing the categories.

What Error 522 Means

When a site is proxied through Cloudflare, visitors connect to the CDN's edge, and the edge opens its own TCP connection to your server, the origin. Error 522 means that connection timed out: the edge got no answer to its connection attempt within about 19 seconds, or the connection opened but no data followed for 90 seconds, according to Cloudflare's documentation. A refused connection gives a different code, 521. A connection that opens and receives the request but sends no HTTP response in time gives error 524.

If You See It on Someone Else's Site

  • Wait and reload: the error page shows that the CDN works and the site's own server does not answer.
  • Nothing on your side helps: clearing the cache or changing browsers does not change the result.
  • Tell the site owner if it lasts, ideally with the time and the Ray ID shown on the error page.

Is the Web Server Listening?

sudo ss -tlnp | grep -E ':80 |:443 '

You should see Nginx or Apache on 0.0.0.0:80 and 0.0.0.0:443, or on the IPv6 equivalent. Nothing listed means the service is stopped: check systemctl status nginx and its log. An address of 127.0.0.1 means it accepts local connections only; correct the listen line.

Does the Firewall Let the Edge In?

If ports 80 and 443 are open to everyone, the firewall is not the cause. If you allow only the CDN's addresses, the list must be complete and current. Cloudflare publishes its ranges as plain text lists. With ufw on Ubuntu and Debian:

for ip in $(curl -s https://www.cloudflare.com/ips-v4); do
  sudo ufw allow proto tcp from "$ip" to any port 80,443
done

With firewalld on AlmaLinux and Rocky Linux:

for ip in $(curl -s https://www.cloudflare.com/ips-v4); do
  sudo firewall-cmd --permanent --add-rich-rule="rule family=\"ipv4\" source address=\"$ip\" port port=\"443\" protocol=\"tcp\" accept"
done
sudo firewall-cmd --reload

Keep your SSH rule in place while you change the firewall. Repeat with the ips-v6 list and the ipv6 family if the server has IPv6, add port 80 the same way if you use it, and review the list from time to time. Also check a firewall in your provider's control panel, and tools such as fail2ban: sudo fail2ban-client status shows whether a jail has banned edge addresses.

Is the Origin IP in DNS Right?

The proxied A record in the Cloudflare DNS settings must hold your server's current address. After a migration it often still points to the old server. Compare it with ip -4 addr show on the server and with the address shown in your provider's control panel.

An Overloaded Server

A server that is out of memory or CPU can stop accepting new connections. Check uptime, free -m, and ss -s for a very large number of connections. Worker limits that cause this are covered in 503 Service Unavailable.

Keepalive Between Edge and Origin

The edge reuses connections to the origin. Cloudflare's documentation lists keepalive turned off on the origin among the causes of 522. Leave it on: in Nginx, do not set keepalive_timeout 0;, and in Apache keep KeepAlive On.

Test the Origin Directly

Bypass the CDN and connect to the server's IP with the right host name:

curl -I --connect-timeout 10 --resolve example.com:443:203.0.113.10 https://example.com/

Run it from a machine whose address your firewall allows. A status line means the origin works; a timeout confirms the connection is blocked or the service is down.

Confirm the Fix

curl -I https://example.com/

The response through the CDN should show 200 and a cf-ray header, which Cloudflare adds to proxied responses. If the edge now reports a handshake failure, see error 525.

Was this answer helpful?
Loading...