Cloudflare Error 521 means Cloudflare tried to connect to the origin web server, but the origin refused the connection or was not available to accept it.
For visitors, Error 521 usually means the website is having an origin-server problem. The site may be down, restarting, misconfigured, or blocking Cloudflare. There is usually not much a visitor can fix locally.
For website owners, Error 521 is a signal to check the origin server first. The web server may be stopped, the port may be closed, the firewall may be blocking Cloudflare IP ranges, or a hosting security rule may be refusing Cloudflare connections.

Quick Answer: How to Fix Cloudflare Error 521
Use the path that matches your role:
| Situation | Best first step |
|---|---|
| You are a visitor | Refresh once, wait, and contact the site owner if the error persists |
| You own the site | Confirm the origin web server is online and listening on the correct port |
| Firewall changed recently | Allow Cloudflare IP ranges through the origin firewall |
| Hosting security is strict | Check fail2ban, ModSecurity, provider firewalls, and DDoS protection rules |
| DNS changed recently | Confirm Cloudflare DNS points to the correct origin IP |
| Traffic spiked | Check worker limits, connection limits, and server load |
Error 521 is closely related to Cloudflare Error 522, but the difference matters. With 521, the origin refuses or cannot accept the connection. With 522, the connection attempt times out.
What Is Cloudflare Error 521?
Cloudflare Error 521 is a Cloudflare 5xx error that appears when the origin web server is down or refuses Cloudflare's connection.
The request path looks like this:
- A visitor requests a Cloudflare-protected website.
- Cloudflare receives the request at the edge.
- Cloudflare tries to connect to the origin server.
- The origin refuses the connection or is unavailable.
- Cloudflare returns Error 521.
The key point is that Cloudflare can be working correctly while the origin is not accepting connections.
Cloudflare Error 521 vs. 522 vs. 520
These errors are easy to confuse because they all involve Cloudflare and the origin.
| Error | Meaning | First place to check |
|---|---|---|
| 520 | Web server returned an unknown error | Origin logs, crashes, invalid responses, oversized headers |
| 521 | Web server is down | Origin service, refused connection, firewall, closed port |
| 522 | Connection timed out | Network path, firewall drops, origin overload, routing |
| 523 | Origin is unreachable | DNS, origin IP, network routing |
| 524 | A timeout occurred | Slow application response after connection |
If Cloudflare cannot connect because the origin refuses the connection, treat it as 521. If Cloudflare waits but the connection never completes, treat it as 522. If Cloudflare connects but receives an unexpected response, check 520. If the failure happens during TLS negotiation, compare it with Cloudflare Error 525.
Origin Server Error vs. Edge Block
Error 521 is an origin-server availability issue, not a normal edge block against a visitor.
That distinction matters for scraping and automation. A Cloudflare access block, such as Error 1020 or a HTTP 403 Forbidden, usually means Cloudflare or the origin evaluated the visitor's request and denied access. Error 521 means Cloudflare could not get the origin web server to accept a connection.
If you are using proxies and see 521, changing proxy IPs usually will not fix the website. The target origin is refusing Cloudflare or unavailable. If you are seeing visitor-specific blocks, look for 403, 429, 1015, or 1020 instead.
If the hostname is served through Cloudflare Tunnel instead of a public origin, compare the symptoms with Cloudflare Error 1033. If the request is routed through Workers and the code fails, use Cloudflare Error 1101.
Why Cloudflare Error 521 Happens
Common causes include:
- The origin web server is offline.
- Nginx, Apache, Caddy, Node, or another web process is stopped.
- The origin is not listening on port 80 or 443.
- The origin firewall blocks Cloudflare IP ranges.
- Hosting provider security rules refuse Cloudflare traffic.
- A DDoS, WAF, or intrusion-prevention tool blocks Cloudflare edges.
- DNS points Cloudflare to the wrong server.
- A load balancer has no healthy upstreams.
- The server is overloaded and refuses new connections.
- IPv6 or IPv4 records point to an address that is not serving the site.
The pattern is usually clear in logs. If the origin never sees the request, check DNS, firewall, provider network rules, and whether the service is listening. If the origin sees the request and immediately refuses it, check web server config, host limits, and security rules.
How to Fix Error 521 as a Visitor
Visitors can only do basic checks:
- Refresh the page once.
- Wait a few minutes.
- Try another browser or network if you want to confirm it is not local.
- Contact the website owner if the error continues.
Unlike a rate limit, Error 521 is usually not caused by refreshing too often or using a proxy. It is a site-side origin problem.
How to Fix Error 521 as a Website Owner
Start with the origin process:
- Confirm the server is powered on and reachable.
- Confirm the web server process is running.
- Confirm the app is listening on the correct port.
- Restart the web server if it crashed.
- Check recent deploys, config changes, and host migrations.
- Inspect error logs for crashes, refused connections, or bind failures.
Then check Cloudflare reachability:
- Allow Cloudflare IP ranges in firewalls and security groups.
- Remove rules that block Cloudflare edge IPs.
- Check fail2ban, ModSecurity, WordPress security plugins, provider firewalls, and DDoS rules.
- Confirm DNS records in Cloudflare point to the correct origin IP.
- Make sure the origin accepts traffic on Cloudflare-supported ports.
- Check load balancer health checks and backend availability.
Do not only restart the server and move on. If 521 comes back, identify whether the recurring cause is crashes, memory pressure, connection limits, firewall automation, or provider-level blocking.
How to Diagnose 521 Quickly
Use this sequence:
- Check whether the origin web server is running.
- Check whether the origin is listening on the expected port.
- Test direct origin connectivity from outside the server.
- Review origin firewall and provider firewall rules.
- Confirm Cloudflare DNS points to the right IP.
- Review web server logs during the error window.
- Compare the timing with deploys, host restarts, traffic spikes, or firewall updates.
If a direct request to the origin IP fails, fix the origin before debugging Cloudflare settings. If direct origin access works but Cloudflare returns 521, the origin may be blocking Cloudflare specifically.
Can Proxies Fix Cloudflare Error 521?
Usually, no. Error 521 is not an IP reputation problem from the visitor side. It means Cloudflare could not get the origin web server to accept the connection.
For scraping and monitoring, treat 521 as target-side downtime or instability. Slow down, avoid retry storms, and log the event separately from access blocks. If your real issue is a rate limit or block, read HTTP 429 Too Many Requests, Cloudflare Error 1015, or HTTP 403 Forbidden.
High-quality proxies help with proxy-related blocks, geo testing, and legitimate monitoring distribution. They do not make a down origin server come back online.
How to Prevent Error 521
For site owners, prevention comes from origin uptime and clean Cloudflare access.
Use these practices:
- Monitor the origin web process.
- Alert when ports 80 or 443 stop accepting connections.
- Keep Cloudflare IP ranges allowlisted.
- Avoid firewall automation that bans Cloudflare edge IPs.
- Watch memory, CPU, disk, worker, and connection limits.
- Use health checks for load-balanced origins.
- Keep DNS records accurate after host migrations.
- Test deploys for service bind failures.
- Track crashes and restart loops instead of hiding them with restarts.
If the origin app crashes under load, fix the application or capacity issue. If a firewall keeps blocking Cloudflare, fix the rule source rather than manually unblocking IPs after each incident.
FAQ
What does Cloudflare Error 521 mean?
Cloudflare Error 521 means Cloudflare tried to connect to the origin web server, but the origin refused the connection or was unavailable.
Is Error 521 a Cloudflare outage?
Usually, no. Cloudflare is reachable enough to return the error page. The issue is normally the origin server, origin firewall, DNS target, hosting provider, or load balancer.
Is Error 521 the same as Error 522?
No. Error 521 means the origin refused or could not accept the connection. Error 522 means Cloudflare's connection attempt timed out.
Can a firewall cause Error 521?
Yes. If the origin firewall blocks Cloudflare IP ranges or refuses connections from Cloudflare edges, visitors can see Error 521.
Does Error 521 mean my IP is blocked?
Usually not. Error 521 is about Cloudflare reaching the origin web server. Visitor-specific blocks are more likely to appear as HTTP 403, Cloudflare Error 1020, HTTP 429, or Cloudflare Error 1015.
Final Thoughts
Cloudflare Error 521 means the origin web server is down, refusing connections, or blocking Cloudflare. Visitors can wait and report the issue, but site owners should check the origin process, listening ports, DNS, firewalls, provider rules, load balancers, and server load.
For related origin connectivity issues, read Cloudflare Error 520, Cloudflare Error 522, and Cloudflare Error 525.
Technical reference: Cloudflare Error 521 documentation.