Cloudflare error 521 "Web server is down" means the origin web server refused the connection from Cloudflare. Cloudflare is working. Your server either is not running or is rejecting Cloudflare's IP addresses.
Cloudflare's own docs (last updated April 2026) name two common causes: the origin application is offline, or a security tool at the origin blocks Cloudflare requests.
Quick fix for site owners:
- Confirm the web server process runs, for example with
systemctl status nginx. - Confirm it listens on the port your SSL/TLS mode uses: port 80 for Flexible, port 443 for Full and Full (strict).
- Allow all Cloudflare IP ranges in your firewall and security tools. Make sure nothing rate limits them.
- Test the origin directly with
curl --resolve(see below).
Visitors: refresh once and wait a few minutes. You cannot fix a 521 from your side. If it continues, tell the site owner.

What "connection refused" means in error 521
A refused or rejected connection is an active answer. Cloudflare sends a TCP connection request, and the origin side answers with a reset or a firewall reject. This happens when:
- No process listens on the port, so the operating system resets the connection.
- A firewall rule rejects Cloudflare's IP address.
- A security tool, such as fail2ban or a hosting DDoS filter, banned Cloudflare IPs.
- The DNS record points at an IP where your web server no longer runs, for example after a migration or a host change.
A timeout is different. If packets are dropped and nothing answers, Cloudflare shows error 522 instead. That is why a "521 connection rejected" search usually ends at a stopped service or a firewall reject rule.
Error 520 vs. 521 vs. 522 vs. 523
| Error | What happened | First check |
|---|---|---|
| 520 | The origin answered with something Cloudflare could not parse | Origin error logs, response headers, crashes |
| 521 | The origin refused the connection | Web server running, port open, Cloudflare IPs allowed |
| 522 | The connection attempt timed out | Firewall drops, overload, network path |
| 523 | Cloudflare cannot reach the origin at all | DNS A/AAAA record, routing, origin IP |
Restarting the web server can fix 521. It will not fix a wrong DNS record (523) or a firewall that silently drops packets (522). If the site runs behind Cloudflare Tunnel, a stopped cloudflared connector shows error 1033 instead of 521.
How to fix error 521 as a website owner
Work from the server outward.
1. Check that the web server runs
sudo systemctl status nginx
Use apache2, httpd, caddy, or your app service name if you do not use Nginx. If the service stopped, read the error log before you restart it. A crash loop, a bad config, or a full disk will stop it again.
2. Check that it listens on the right port
sudo ss -tlnp | grep -E ':(80|443)\b'
You need a listener on port 443 if Cloudflare uses Full or Full (strict) mode. Flexible mode connects on port 80. A common 521 cause is Full mode with no HTTPS listener on the origin. In that case, install a certificate on the origin, for example a free Cloudflare Origin CA certificate, and enable HTTPS.
Also check the listener address. A server bound to 127.0.0.1 only will refuse outside connections even though ss shows it listening.
3. Test the origin directly
This command connects to your origin IP but sends the real hostname. Replace example.com and 203.0.113.10 with your values:
curl -v --resolve example.com:443:203.0.113.10 https://example.com/
Connection refusedmeans nothing listens on 443, or a firewall rejects you.- A normal response means the server works. If Cloudflare still shows 521, the origin probably blocks Cloudflare IPs only.
- A long wait that ends in a timeout points to 522, not 521.
For Flexible mode, test port 80 with curl -v --resolve example.com:80:203.0.113.10 http://example.com/.
Run the test from a machine outside your server's network. A request from the server itself skips the firewall rules that decide the outcome.
4. Allow Cloudflare IP addresses
Cloudflare publishes the current IPv4 and IPv6 ranges at https://www.cloudflare.com/ips/. Cloudflare says the ranges do not change often, and it lists changes before they go live. Add them to every layer that filters traffic:
- The host firewall, such as
ufw,firewalld, oriptables - Cloud security groups and provider firewalls
- fail2ban, ModSecurity, and WordPress security plugins
- Hosting DDoS or rate-limit filters
With ufw, this loop allows all IPv4 ranges on ports 80 and 443:
for ip in $(curl -s https://www.cloudflare.com/ips-v4); do
sudo ufw allow from "$ip" to any port 80,443 proto tcp
done
Repeat with https://www.cloudflare.com/ips-v6 if your origin has an AAAA record. For fail2ban, check the active bans with sudo fail2ban-client status <jail> and look for Cloudflare addresses. Put the loop in a cron job or deploy script, so a changed range does not bring the 521 back months later.
5. Check limits and load balancers
An overloaded server can refuse new connections. Check connection limits, worker limits, CPU, and memory. If a load balancer sits in front of the app, confirm it has healthy backends.
6. Pause Cloudflare to isolate the problem
If you cannot tell whether the fault is at the origin or in the Cloudflare path, pause Cloudflare for a few minutes. In the dashboard, open the domain, go to Overview, then Advanced Actions, then Pause Cloudflare on Site. Per Cloudflare's docs, the change takes five minutes or less, and traffic then goes straight to your origin without WAF or Cloudflare SSL.
If the site loads while paused, the origin works and the problem is a block on Cloudflare IPs or an SSL/TLS mode mismatch. If it still fails, the server is down. Unpause afterwards, because the origin IP is exposed while Cloudflare is paused.
7. Ask the host
If all checks pass, contact your hosting provider with the time and Ray ID. Ask them to review the origin error logs and any network filter in front of your server.
WordPress sites
On WordPress, security plugins are the usual cause. Wordfence and similar plugins can rate limit or block Cloudflare IPs when many requests arrive from a few addresses. Disable the plugin's firewall for a minute to test, then add the Cloudflare ranges to its allowlist. A server-side cache or caching plugin that crashes PHP workers can also trigger refusals under load.
How to fix error 521 as a visitor
- Refresh the page once.
- Wait a few minutes.
- Contact the website owner if the error stays.
Error 521 is not caused by your browser, your IP, or too many refreshes. It is a site-side problem.
Can proxies fix error 521?
No. Error 521 is about the connection between Cloudflare and the origin. Your IP is not part of that connection, so a new proxy changes nothing.
If you scrape or monitor a site and see 521, treat it as downtime on the target. This matters most on ticketing and retail checkouts during a drop, where origins often struggle under load. Pause or slow down, and do not retry in a tight loop. Log 521 apart from access blocks so the two do not mix in your metrics. If the same target returns 403, 429, or a Cloudflare 1020 page instead, that is a block on your IP. See HTTP 403 Forbidden and Cloudflare error 1020. Dedicated ISP proxies help with those blocks, not with a 521.
How to prevent error 521
- Monitor the web server process and alert when it stops.
- Alert when ports 80 or 443 stop accepting connections.
- Keep Cloudflare IP ranges allowlisted, and update them when Cloudflare changes the list.
- Exclude Cloudflare IPs from fail2ban and automatic ban tools.
- Watch memory, CPU, disk, and connection limits.
- Confirm the SSL/TLS mode and DNS records still match the origin after a migration.
FAQ
What does Cloudflare error 521 mean?
It means the origin web server refused Cloudflare's connection. The server is offline, not listening on the port, or blocking Cloudflare.
What does "web server is down, origin refused connection" mean?
It is the same error. Cloudflare reached the origin IP, but the origin rejected the connection instead of serving the page.
How do I fix error 521 on my site?
Start the web server, confirm it listens on port 80 or 443 to match your SSL/TLS mode, and allow Cloudflare IP ranges in every firewall and security plugin. Then test the origin with curl --resolve from outside your network.
Is error 521 a Cloudflare outage?
No. Cloudflare returns the error page, so Cloudflare works. The fault is on the origin server or its firewall.
Can a firewall cause error 521?
Yes. A firewall or security plugin that blocks Cloudflare IP ranges is one of the two main causes Cloudflare lists.
Is error 521 the same as error 522?
No. Error 521 means the origin refused the connection. Error 522 means the connection attempt timed out.
Can an SSL/TLS mode cause error 521?
Yes. In Full or Full (strict) mode Cloudflare connects on port 443. If the origin has no HTTPS listener or no valid certificate there, the connection fails. Switch the origin to HTTPS, or use Flexible mode only as a short test.
Final thoughts
Error 521 is nearly always one of three things: a stopped web server, a closed or wrong port, or a firewall that bans Cloudflare. Run ss and curl --resolve first, since they separate those three in under a minute. Then allowlist the Cloudflare ranges in every layer and automate the update. If the origin is fine and the error keeps coming back, send your host the Ray ID.
Technical reference: Cloudflare error 521 documentation.