Troubleshooting guide
Cloudflare error 521: web server is down
A 521 means your server actively refused Cloudflare's connection. Either nothing is listening on the port, or something on the server is turning Cloudflare away.
5 min read10 sectionsUpdated
On this page
What error 521 means
Cloudflare tried to open a TCP connection to your origin on port 80 or 443 and the server answered with a refusal (a TCP reset). That is different from a timeout (522), where the server never answers at all.
| Error | What Cloudflare saw | Where to look first |
|---|---|---|
| 520 | A connection, then an empty, invalid or reset response | Origin application and web server error logs |
| 521 | The origin actively refused the TCP connection | Is the web server running; does the firewall allow Cloudflare |
| 522 | No TCP connection within Cloudflare's time limit | Server load, firewall dropping packets, wrong DNS record |
| 524 | A connection, but no HTTP response within 100 seconds | Slow requests: long queries, reports, exports, uploads |
The usual causes
- The web server is stopped or crashed: nginx, Apache, Caddy or your application server is not running, or failed after a configuration change.
- It listens on the wrong port or address, for example only on 127.0.0.1, or on 8080 while Cloudflare connects to 443.
- A firewall blocks Cloudflare. Hosting firewalls, iptables rules, fail2ban or a security plugin may block Cloudflare's addresses, often after seeing many requests from them (all your visitors arrive through them).
- SSL mode mismatch. With an SSL mode that connects to the origin over HTTPS, an origin that does not listen on 443 refuses the connection.
- The DNS record points at an old server that no longer runs the site.
# on the server: is anything listening on 80 and 443?
sudo ss -ltnp | grep -E ':(80|443) '
# is the web server running?
sudo systemctl status nginx
# from outside, bypassing Cloudflare
curl -sv --resolve example.com:443:203.0.113.10 https://example.com/ -o /dev/null
# firewall rules that drop or reject
sudo iptables -S | head -50Fix it
- Start or fix the web server, and run its config test (
nginx -t) before reloading, so a typo does not take it down again. - Listen on the right address and ports:
0.0.0.0:443(or the public interface), and port 80 if Cloudflare connects over HTTP. - Allow all of Cloudflare's IP ranges in every firewall on the path, and exclude them from rate limiting and ban tools; Cloudflare publishes the list on its website.
- Match the SSL mode to what the origin supports: if the origin serves HTTPS, use a mode that connects over HTTPS with a valid certificate on the origin.
- Check the DNS record in the Cloudflare dashboard against the server's current IP address.
Catch it before your visitors do
Cloudflare's error pages hide the cause, so measure both sides:
- Check the public URL through Cloudflare with an uptime monitor from several regions. That is what visitors get, 52x errors included.
- Check the origin directly with a second monitor on the origin's address or a health endpoint that bypasses Cloudflare. If only the first one fails, the problem is between Cloudflare and your server; if both fail, it is the server.
- Alert on the status code, not only on "down". A rule for any 52x response on the public check tells you which of the four errors it is before anyone opens a log.
- Keep the CF-Ray ID. It is in the error page and in the cf-ray response header; Cloudflare support and your own logs can be matched with it.
With APM on the origin you can also see the request that took 100 seconds behind a 524, instead of guessing.
How is 521 different from 522?
521 means the origin refused the connection, usually because nothing is listening or a firewall rejects it. 522 means the connection attempt timed out, usually because the server is overloaded or packets are dropped silently.
My site works when I visit the IP address directly. Why 521?
Your own IP is probably allowed while Cloudflare's ranges are blocked or rate limited. Check firewall, security plugin and fail2ban rules for Cloudflare's addresses.
Does 521 affect SEO?
Short outages rarely do. If crawlers keep getting 5xx errors for days, pages can drop from the index, which is why alerting on 521 within minutes matters.
Cloudflare 520: unknown error
The origin answered with something Cloudflare could not use.
Cloudflare 522: connection timed out
The origin never completed the connection.
Cloudflare 524: a timeout occurred
The origin connected but answered too slowly.
Connection timed out
When the browser itself cannot connect.
Check it now, free
- Is Cloudflare down? Live status: checked every few minutes, with outage history.
- Website down checker: Is it down for everyone or just me? Check any site now.
Related reading
- Cloudflare error 1016 "Origin DNS error": how to fix it: Fix Cloudflare error 1016 Origin DNS error: CNAME records pointing to names that do not resolve, deleted origins and load balancer pools, with checks.
- Cloudflare error 530: how to fix it: Fix Cloudflare error 530, usually shown with error 1033 (Argo Tunnel error) or 1016: stopped cloudflared tunnels, deleted tunnels and origin DNS problems.
- Cloudflare error 1015 "You are being rate limited": how to fix it: Fix Cloudflare error 1015 "You are being rate limited": what triggers rate limiting rules, how long blocks last, and how site owners tune them.
- 500 Internal Server Error: how to find the cause: A 500 error means your code failed. Find the exception behind it fast with logs, traces and error tracking, and learn how to prevent repeats.
- WordPress "Error establishing a database connection": fix: Fix WordPress Error establishing a database connection: check wp-config credentials, MySQL status, connection limits and damaged tables with safe commands.
- Cloudflare error 523: origin is unreachable: Fix Cloudflare error 523 Origin is Unreachable: wrong DNS IPs, routing problems at the host and firewalls, with tests that confirm where traffic stops.
Watch your own site and services with VitalRix
Uptime checks, APM, logs, real-user monitoring, alerts and status pages in one place. Every product has a free tier and no credit card is needed.