521 Web Server Is Down

Cloudflare - Origin refused the connection

521 Web Server Is Down (Cloudflare)

What It Means

521 Web Server Is Down is a Cloudflare-specific error. It means Cloudflare tried to open a TCP connection to your origin server but the connection was actively refused. Cloudflare itself is working fine — the problem is between Cloudflare and your origin. In practice, your web server is down, crashed, or rejecting connections from Cloudflare's IP ranges.

Error 521: Web server is down
Host Error
The web server is not returning a connection. As a result,
the web page is not displaying.

Common Causes

  • Origin server down: Nginx/Apache stopped or crashed
  • Firewall blocking Cloudflare: Cloudflare's IP ranges not allowlisted
  • Wrong port: Origin not listening on 80/443 as expected
  • Server overloaded: Connections dropped under heavy load
  • Deployment downtime: Origin offline during a deploy or restart
  • Proxy just enabled: Orange-cloud turned on before allowlisting Cloudflare IPs

How to Fix It

# 1. Confirm the web server is running
systemctl status nginx
systemctl status apache2

# 2. Verify it's listening on the expected port
ss -tlnp | grep -E ':80|:443'

# 3. Test the origin directly by IP (bypassing Cloudflare)
curl -v --resolve example.com:443:ORIGIN_IP https://example.com

# 4. Allowlist Cloudflare IP ranges in your firewall (UFW example)
for ip in $(curl -s https://www.cloudflare.com/ips-v4); do
  sudo ufw allow from $ip to any port 443 proto tcp
done
  • Restart the web server and check its error logs (journalctl -u nginx -n 50)
  • Allowlist Cloudflare's IP ranges in your firewall and cloud security groups
  • Confirm the origin listens on the port Cloudflare connects to (80 or 443)
  • Check resource limits (CPU, memory, max connections) if it fails under load
  • If you just enabled the orange-cloud proxy, allowlist Cloudflare before traffic shifts

521 vs 522 vs 523

  • 521 Web Server Is Down: Origin actively refused the connection (TCP reset or nothing listening)
  • 522 Connection Timed Out: Connection attempt timed out — packets silently dropped or origin unreachable
  • 523 Origin Is Unreachable: Cloudflare can't route to the origin at all (bad DNS/IP)

Shorthand: 521 = refused, 522 = timed out, 523 = unreachable. This is similar to a plain connection refused error, but reported by Cloudflare on your behalf.

How to Monitor for 521 Errors

A 521 means visitors see an error page even though Cloudflare is healthy — your origin is down. UptimeSignal checks your site from outside your network and detects Cloudflare 521 responses, alerting you the moment your origin stops accepting connections. Because the check runs externally, it catches firewall changes that block Cloudflare's IPs and origin crashes that internal health checks would miss. See also 522 Connection Timed Out.

Frequently Asked Questions

What does Cloudflare error 521 mean?
521 Web Server Is Down means Cloudflare tried to open a connection to your origin server but it was actively refused. Cloudflare is up; the problem is your origin — it's down, crashed, or rejecting connections from Cloudflare's IP ranges.
What causes a 521 error?
The origin web server is stopped or crashed, a firewall or security group blocks Cloudflare's IPs, the origin listens on the wrong port, the server is overloaded and dropping connections, the origin is offline during a deploy, or Cloudflare's IPs weren't allowlisted after enabling the proxy.
How do I fix a Cloudflare 521 error?
Confirm the web server is running (systemctl status nginx), allowlist Cloudflare's IP ranges in your firewall, verify it listens on port 80/443, test the origin directly by IP, review resource limits if it drops connections under load, and restart the server while checking error logs.
What's the difference between 521 and 522?
521 means Cloudflare's connection to the origin was actively refused (TCP reset or nothing listening). 522 Connection Timed Out means the connection attempt timed out with no response, usually because a firewall is silently dropping packets. 521 = refused, 522 = timed out.
Is a 521 error Cloudflare's fault or mine?
It's almost always an origin-side issue, not Cloudflare's. Cloudflare returns 521 specifically because it could reach the network but your origin refused the connection. Start by checking that your web server is running and that your firewall allows Cloudflare's IP ranges.

Know when your origin goes down behind Cloudflare

UptimeSignal checks from outside your network and detects 521 errors within minutes.

Monitor all your endpoints. 25 monitors free, unlimited for $10/month.

Related Errors & Resources