What is the difference between Cloudflare 521 and 522?
521 means the origin actively refused the connection immediately (RST/port closed/firewall reject). 522 means packets were silently dropped and the TCP handshake timed out.
Cloudflare Error 521 means your origin server actively refused Cloudflare's TCP connection (`ECONNREFUSED`). Either Nginx/Apache/Caddy is stopped, not listening on port 443, or a firewall is actively rejecting Cloudflare IPs.
# Check listening sockets on origin
ss -tlnp | grep -E ':80|:443'
# Verify Nginx is active and config is valid
sudo nginx -t && sudo systemctl restart nginx
# Ensure UFW allows HTTPS (or restrict specifically to Cloudflare IP ranges)
sudo ufw allow 443/tcp
curl -i -sS --connect-timeout 5 https://ORIGIN_IP -H 'Host: example.com' -k
521 means the origin actively refused the connection immediately (RST/port closed/firewall reject). 522 means packets were silently dropped and the TCP handshake timed out.
Full (Strict) requires your origin to listen on port 443 with a valid SSL certificate (such as a free Cloudflare Origin Certificate or Let's Encrypt cert).
Yes! If fail2ban sees Cloudflare's edge IPs instead of real visitor IPs, it can ban Cloudflare itself. Configure `real_ip_header CF-Connecting-IP` and whitelist Cloudflare IPs.