Why Am I Getting Cloudflare Error 521: Web Server Is Down?

The error page blames your web server, and it is right — but “down” covers four different situations, and one of them is a Cloudflare setting you changed yourself.

Updated September 1, 2026 · 7 min read

Cloudflare error 521 means your origin server refused the connection Cloudflare tried to open. Something answered, and the answer was no. Either the web server is not running, or it is not listening on the port your encryption mode requires.

Error 521 is generated at Cloudflare’s edge, not by your application, so none of your own error handling runs and none of your logs necessarily record it. That is already useful information: the visitor reached Cloudflare perfectly well, so whatever is broken sits on the second hop, between Cloudflare and your server. Your browser records the response as HTTP status 521, which is not a standard status code at all — it is one Cloudflare defines for itself, so “Cloudflare 521” and “error code 521” describe the same single thing. A 521 error also only happens on a proxied record— on a DNS-only record there is no proxy in the path to be refused, and the visitor would simply see your server’s own failure instead.

Refused, not unreachable

Where a Cloudflare 521 error happens on the path to your originVisitorreaches Cloudflare normallyCloudflare edgeopens a TCP connection to the originrefused at once(TCP reset)Origin serveranswers: refused, not silentError 521web server is down
A 521 arrives almost instantly, because the origin answered. Silence on the same hop produces 522 instead, after Cloudflare has spent 19 seconds retrying.

Cloudflare defines error 521 as the origin web server refusing connections, and that word does most of the diagnostic work. A refusal is a reply. Your server, or something in front of it, received Cloudflare’s packet and sent back a TCP reset — the same thing that produces connection refused when you run curl against a port with nothing behind it. Because it is a reply rather than a wait, a 521 error appears almost instantly.

This is the cleanest way to tell it apart from its neighbours. If Cloudflare had been ignored rather than refused it would have kept retrying and reported 522 after 19 seconds. If there had been no network route to your address at all, it would have reported 523. One misconfigured firewall can produce either 521 or 522 depending on a single word in the rule: REJECT sends the reset and gets you a 521, DROP stays quiet and gets you a 522.

The cause people miss: which port Cloudflare knocks on

Before touching the firewall, check this, because it is the one cause of error 521 that originates in the Cloudflare dashboard rather than at your origin. Your SSL/TLS encryption modedecides which port Cloudflare opens a connection to at your server, and Cloudflare’s own 521 documentation states the mapping plainly:

Encryption modeOrigin port Cloudflare connects toWhat the origin must have
FlexiblePort 80A plain HTTP listener. No certificate needed on this hop.
FullPort 443HTTPS enabled. Any certificate, including a self-signed one.
Full (strict)Port 443HTTPS enabled with a certificate that validates — a public CA, or a Cloudflare Origin CA certificate.

So a server that only ever spoke plain HTTP is refusing connections on port 443 the moment the mode moves to Full or Full (strict) — nothing is bound there, so the kernel resets every incoming connection, and every request returns error 521 from then on. This is why 521 errors so often start right after somebody “improved the SSL settings”, and why the fix is either to enable HTTPS at the origin or to move the mode back. Note that this is a different failure from a bad certificate: if your origin does answer on 443 but presents a certificate Cloudflare will not accept, you get 526 rather than 521.

The four causes, in the order worth checking

  1. The web server process is not running. Cloudflare lists an offlined origin application as one of the two most common causes. A crashed nginx, an httpd that failed to restart after a config reload, or a container that exited will all refuse connections while the host itself stays perfectly reachable. Check the service status and the origin error log for the crash.
  2. The server is running but not on the port your mode needs. The case above: bound to 80 while Cloudflare is knocking on 443, or the reverse.
  3. A firewall is rejecting Cloudflare’s addresses.The other most common cause. Security software at the origin may block legitimate connections from particular Cloudflare IPs, so Cloudflare’s advice is to allow all Cloudflare IP ranges at the origin rather than a subset. Rate limiting counts here too: a rule that trips after a burst will produce intermittent 521 errors that look like a flapping server.
  4. The origin does not support HTTPS at all. Distinct from being bound to the wrong port — the service is there, but TLS was never configured. The remedy is the same as case two, with more work: install a certificate, or drop back to a mode that uses port 80 while you do.

Confirming it yourself

Both of the checks that matter can be run in a minute. The first asks your origin what it is actually listening on; the second bypasses Cloudflare entirely and knocks on the origin address directly, so a connection refusedhere reproduces the 521 error outside the proxy and proves the fault is not Cloudflare’s.

# On the origin, list what is actually listening
ss -lntp | grep -E ':(80|443)\s'

# From anywhere, knock on the origin address directly
curl -sv --connect-timeout 5 https://203.0.113.10/ --resolve example.com:443:203.0.113.10

If the direct request succeeds while the proxied one still returns a 521 error, the difference is almost always which addresses are allowed: your own IP is permitted and Cloudflare’s ranges are not. If the direct request is refused too, the origin is at fault regardless of Cloudflare, and the first two causes above are where to look.

Where 521 sits among the origin errors

The whole 52x family describes the Cloudflare-to-origin hop, and they are distinguished only by how the origin failed:

ErrorWhat the origin didTypical first move
521Refused immediately — sent a resetConfirm the service runs and listens on the port your encryption mode needs
522Said nothing until the clock ran outAllow Cloudflare’s IP ranges; check whether the origin is overloaded
523Could not be reached — no route to the addressVerify the A record, and the route tables between your network and Cloudflare

A short rule for the three: 521 is a refusal, 522 is silence, 523 is no route. When you do escalate, Cloudflare asks you to give your hosting provider the specific error code, the time and timezone it happened, and the exact URL — and to check the logs of any load balancer, cache, proxy or firewall sitting between Cloudflare and the web server, because the cause is not always in the origin’s own log. The 5xx index covers the rest of the family, and the encryption modes reference covers the setting behind the port trap above.

FAQ

What does Cloudflare error 521 mean?

It means the origin web server refused the connection Cloudflare tried to open. Cloudflare reached your server's address and got an immediate rejection rather than a response, so it returned error 521, web server is down, to the visitor.

What is the difference between error 521 and error 522?

Both describe the same hop between Cloudflare and your origin, but not the same behaviour. A 521 error means the origin actively refused the connection, so Cloudflare knew straight away. A 522 means the origin said nothing at all and Cloudflare gave up after 19 seconds. A firewall that rejects packets produces 521; the same firewall set to drop them produces 522.

Can I fix a 521 error from the Cloudflare dashboard?

Usually not, because the fault is at your origin rather than at Cloudflare. The one exception worth checking first is the SSL/TLS encryption mode, which decides whether Cloudflare connects to port 80 or port 443 at your origin. If the mode was changed to Full or Full (strict) and your server only listens on port 80, error 521 starts immediately and changing that setting back stops it.

Why do I get a 521 error only after switching to Full (strict)?

Because the encryption mode changes which port Cloudflare connects to. Cloudflare connects to port 80 in Flexible mode, and to port 443 in Full and Full (strict). A server configured for plain HTTP only is not listening on 443, so it refuses the connection and every request returns error 521 until HTTPS is enabled at the origin.

I am a visitor, not the site owner. Can I do anything about a 521?

No. Error 521 is generated at Cloudflare's edge because the website's own server refused the connection, and nothing on your device or network causes it. Cloudflare's support policy is that site visitors should report the problem to the site owner; reloading later is the only useful action.

Manage this from your phone

Orange Cloud is a native iOS and Android client for Cloudflare. Sign in with Cloudflare OAuth and flip proxy status, edit DNS records, and read traffic analytics from anywhere.

Get Orange Cloud