SiteError.comYour friendly guide to HTTP status codes
Status CodesBlog
  1. Home
  2. Blog
  3. Understanding Cloudflare 521 Web Server Is Down: When Your Origin Refuses the Connection

Understanding Cloudflare 521 Web Server Is Down: When Your Origin Refuses the Connection

October 1, 20267 min read
Cloudflare

521 Web Server Is Down sounds alarming, but it's really Cloudflare reporting one specific, narrow fact: it tried to open a TCP connection to your origin, and the origin said no. Not "didn't answer in time" — that's 522. Not "couldn't find a route there" — that's 523. A 521 means the connection attempt reached your infrastructure and was actively refused. This post covers Cloudflare's two documented causes, why a firewall misconfiguration is often more likely than an actual outage, and how to verify each one.

What Is a 521?

A 521 means Cloudflare reached the network your origin lives on, attempted to open a TCP connection, and that connection was refused.

Not a standard code. Like the rest of the 52x family, 521 has no RFC and no entry in the IANA status code registry — it's Cloudflare's own vocabulary for describing failures in the Cloudflare-to-origin leg of a request, a layer that simply doesn't exist for a site not running behind Cloudflare's proxy.

Cloudflare's documentation is direct about the mechanism:

Error 521 occurs when the origin web server refuses connections from Cloudflare. Security solutions at your origin may block legitimate connections from certain Cloudflare IP addresses. — Cloudflare documentation, Error 521

In plain English: this is a TCP-level rejection — a RST packet or an immediate connection refusal — not a slow or missing response. Cloudflare's edge got an answer, and the answer was "not welcome here."

The Two Causes That Actually Matter

Cloudflare's docs narrow this down further than most 5xx pages: "The two most common causes of 521 errors are: Offlined origin web server application. Blocked Cloudflare requests." That's it — two buckets, and it's worth treating them as genuinely different investigations rather than one vague "server issue."

1. The origin's web server application isn't running. The process crashed, was never started after a deploy, ran out of memory and got killed by the OS, or the host itself rebooted and the service didn't come back. This is the scenario the name "Web Server Is Down" is describing literally — nothing is listening on the port Cloudflare is trying to reach.

2. Something at the origin is actively blocking Cloudflare. This is the one that catches people off guard, because from the outside it looks identical to the server being down — but the server is perfectly healthy, just refusing a specific set of IPs. A firewall rule, iptables policy, security group, or a security plugin (Fail2ban, ModSecurity, a WAF) can end up blocking Cloudflare's edge IPs, especially after a security hardening pass that didn't account for traffic arriving from Cloudflare rather than directly from visitors.

Because visitor IPs never touch your origin directly when you're proxied through Cloudflare, every request your server sees comes from Cloudflare's IP ranges. If those ranges aren't explicitly allowed, a well-intentioned rate limit or geo-block can take your entire site down for everyone, all at once — while looking, from your monitoring, exactly like an outage.

Checking Each Cause

Cloudflare's resolution guidance maps directly onto the two causes above:

Ensure your origin web server is responsive. Review origin web server error logs to identify web server application crashes or outages. Confirm Cloudflare IP addresses are not blocked or rate limited. Allow all Cloudflare IP ranges in your origin web server's firewall or other security software. — Cloudflare documentation, Error 521

Practically, that means:

  1. Confirm the process is actually running. SSH in (or check your host provider's console) and verify the web server process is up and bound to the expected port. Check its own error logs for a crash around the time the 521s started.
  2. Allowlist Cloudflare's published IP ranges. Cloudflare maintains a current IP list specifically so origin firewalls can allow it. If your firewall, iptables rules, or hosting provider's security group use a stale or partial copy of that list, new Cloudflare IPs added over time will start getting blocked — this is a genuinely common cause of 521s appearing on a site that was working fine for months.
  3. Check your SSL/TLS mode against what the origin is actually listening on. Cloudflare's docs are specific here: if your SSL/TLS mode is Full or Full (Strict), confirm the origin supports HTTPS and has a Cloudflare Origin Certificate (or another certificate that satisfies those modes) installed. Cloudflare's guidance: "Ensure that your origin web server application is actively bound and listening on the port required by your SSL/TLS mode: Port 80 for Flexible, or Port 443 for Full and Full (Strict)." A server listening on the wrong port for the configured SSL/TLS mode looks exactly like a refused connection from Cloudflare's side.

521 vs. the Rest of the Cloudflare 52x Family

CodeMeaningWhat happened at the TCP layer
520 Web Server Returns Unknown ErrorConnection succeeded, but the HTTP response was unparseableConnected fine; the response was the problem
521 Web Server Is DownOrigin actively refused the connectionReached the origin's network; the origin said no
522 Connection Timed OutNo response within Cloudflare's connection timeout windowReached the origin's network; nobody answered in time
523 Origin Is UnreachableNo network route to the origin IP existsNever reached the origin's network at all
503 Service UnavailableThe standard-HTTP way for a reachable server to say "not right now"Server answered deliberately, unlike 521's refusal

The distinguishing question for 521 specifically: did the origin's network stack actively reject the connection (521), or did the packet just vanish into a timeout (522) or a routing dead-end (523)? A refusal implies something is listening at the network layer — a firewall, a load balancer, the OS itself — and chose to say no.

Common Pitfalls

  1. Assuming a firewall change is safe because "it only blocks direct traffic." If your site is fully proxied through Cloudflare, there is no meaningful category of "direct traffic" hitting your origin except Cloudflare itself and whatever's misconfigured. Blocking IPs you don't recognize in your access logs can mean blocking Cloudflare's edge.
  2. Using a hardcoded or outdated Cloudflare IP list. Cloudflare's ranges change periodically. A firewall rule copied from an old blog post or a one-time export will drift out of date — pull from Cloudflare's published IP list directly, and if possible, automate the refresh.
  3. Debugging port/SSL-mode mismatches as if they were application bugs. A server correctly running but listening on port 8080 while Cloudflare's SSL/TLS mode expects port 443 will produce the same 521 as a genuinely crashed server. Check the port and SSL/TLS mode pairing before diving into application logs.
  4. Treating every 521 as an outage that needs a restart. If the process is healthy and just blocked, restarting it changes nothing. Confirm which of the two documented causes you're dealing with before reaching for a fix.

Wrapping Up

521 means the origin was reachable at the network level and actively refused Cloudflare's connection — it's a much narrower claim than "the server is down," even though that's the code's name. The rules of thumb:

  • 521 = a refused TCP connection, not a timeout (522) or an unreachable route (523).
  • Cloudflare's docs narrow it to two causes: the origin process isn't running, or something is blocking Cloudflare's IPs.
  • Always check your firewall/security software against Cloudflare's current published IP ranges — stale allowlists are a frequent, invisible cause.
  • Verify the origin is listening on the port your SSL/TLS mode expects (80 for Flexible, 443 for Full/Full Strict) before assuming the process crashed.

For more, see our pages on 521 Web Server Is Down, 520 Web Server Returns Unknown Error, 522 Connection Timed Out, and 523 Origin Is Unreachable, plus our 520 post and the standard-HTTP 502 Bad Gateway deep-dive for the vendor-neutral equivalent.

Full Reference

521 Web Server Is Down

The origin server refused the connection from Cloudflare. The origin's web server is not running or a firewall is blocking Cloudflare.

Related Status Codes

🤷520Web Server Returns Unknown Error🚫521Web Server Is Down⏱️522Connection Timed Out🗺️523Origin Is Unreachable🕐524A Timeout Occurred🔐525SSL Handshake Failed📜526Invalid SSL Certificate🚂527Railgun Error
Back to Blog

Popular Status Codes

  • 200 OK
  • 301 Moved Permanently
  • 302 Found
  • 400 Bad Request
  • 401 Unauthorized
  • 403 Forbidden
  • 404 Not Found
  • 500 Internal Server Error
  • 502 Bad Gateway
  • 503 Service Unavailable

Compare Codes

  • 401 vs 403
  • 301 vs 302
  • 404 vs 410
  • 500 vs 502
  • Compare any codes →

Categories

  • Informational
  • Success
  • Redirection
  • Client Error
  • Server Error
  • NGINX
  • Cloudflare
  • AWS ELB
  • Microsoft IIS

Tools

  • Cheat Sheet
  • Status Code Quiz
  • URL Checker
  • API Playground
  • Blog

© 2026 SiteError.com. All rights reserved.