Cloudflare Error 522 on Nginx

Nginx stops accepting connections once worker_connections is exhausted, which Cloudflare sees as a refused handshake rather than a slow page.

Why it happens on Nginx

Nginx stops accepting connections once worker_connections is exhausted, which Cloudflare sees as a refused handshake rather than a slow page.

The fix on Nginx

Raise worker_connections and worker_processes, confirm the box is not out of file descriptors (ulimit -n), and check that ufw or the cloud firewall allows 443 from Cloudflare's ranges.

If that didn't fix it

Nginx has its own failure mode, but Cloudflare Error 522 has a wider set of causes. The most common one overall is: The origin firewall silently drops Cloudflare's IP ranges.

Allowlist Cloudflare's IP ranges with an accept rule, and make sure the default policy does not drop them earlier in the chain.

Check your own domain

Probing the origin address directly shows whether it is reachable from outside Cloudflare, which immediately tells you whether the fault is the firewall or the host.

Frequently asked questions

Why does Cloudflare Error 522 happen on Nginx?

Nginx stops accepting connections once worker_connections is exhausted, which Cloudflare sees as a refused handshake rather than a slow page.

How do I fix Cloudflare Error 522 on Nginx?

Raise worker_connections and worker_processes, confirm the box is not out of file descriptors (ulimit -n), and check that ufw or the cloud firewall allows 443 from Cloudflare's ranges.

What does Cloudflare Error 522 mean?

Cloudflare tried to open a connection to the origin and nothing answered before the timeout. Usually a firewall silently dropping Cloudflare's traffic, an overloaded origin, or a wrong origin IP.