Cloudflare Error 522 on Nginx
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.
Is Cloudflare Error 522 happening on your 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.
Free, no signup. Runs from outside your network, which is the only way to tell a server fault from a local one.
If that didn't fix it
Nginx has its own failure mode, but Cloudflare Error 522 has a wider set of causes that apply everywhere. The most common one overall is: the origin firewall silently drops cloudflare's ip ranges.
All causes and fixes for Cloudflare Error 522