Home/Blog/How to Fix Cloudflare Error 521 in 2026 (Web Server Is Down)

How to Fix Cloudflare Error 521 in 2026 (Web Server Is Down)

Server room with a red error warning screen — Cloudflare error 521 web server is down

What Is Cloudflare Error 521?

Cloudflare error 521, shown as “Web server is down”, appears when Cloudflare receives a visitor’s request but cannot connect to your origin server. The connection is refused outright — usually on port 80 or 443 — so Cloudflare has no page to show and displays the error instead. Learning how to fix Cloudflare error 521 starts with one fact: the problem is always on the origin side, never in the visitor’s browser. If you own the site, the fix is in your server, firewall or DNS settings.

Error 521 differs from its neighbours. A 522 means the connection timed out, and a 525 means the SSL handshake failed. With 521, the connection is refused before either can happen — so check the web server process, the ports it listens on, and anything blocking Cloudflare’s IP addresses.

What Causes Cloudflare Error 521?

Most 521 errors come from one of five causes:

  • The origin web server is stopped or crashed. Nginx, Apache or LiteSpeed is no longer running, so nothing answers on port 80 or 443. A failed deployment, a full disk or exhausted memory can stop the service without warning.
  • A firewall blocks Cloudflare IP addresses. A server firewall, cloud security group, host WAF or fail2ban can mistake Cloudflare’s traffic for an attack. This is the most common cause.
  • The SSL/TLS mode does not match the origin. If Cloudflare is set to Full or Full (strict), it must reach the origin over HTTPS on port 443. If the origin only serves HTTP, the connection is refused.
  • DNS points to the wrong origin. A stale A record sends requests to an IP address where no web server is listening.
  • The hosting provider filters Cloudflare traffic. Some shared hosts rate-limit or block traffic from proxy networks, even when the server itself is fine.

How to Fix Cloudflare Error 521

1. Check That Your Origin Server Is Running

Start at the origin. Log in to your hosting panel or connect over SSH and check whether your web server is running. On Linux, run sudo systemctl status nginx (or apache2 for Apache) and sudo ss -ltnp to confirm ports 80 and 443 are listening. If the service has stopped, restart it and check the error log at /var/log/nginx/error.log for the reason.

2. Allowlist Cloudflare IP Addresses in Your Firewall

If the server is running but still refuses Cloudflare, your firewall is the prime suspect. Cloudflare publishes its full IP ranges at cloudflare.com/ips. Add every range to your server firewall, your cloud security group and your host’s firewall panel, and add them to fail2ban’s ignoreip setting so legitimate traffic is never banned. If fail2ban has already banned Cloudflare addresses, unban them with sudo fail2ban-client unban <IP>.

3. Check Your SSL/TLS Encryption Mode

Open the Cloudflare dashboard, go to SSL/TLS → Overview, and check the encryption mode. Flexible mode needs the origin to answer on port 80, while Full and Full (strict) need it on port 443 with a valid certificate. If your origin has no HTTPS service, switch to Flexible temporarily, then install a certificate and move back to Full (strict). For a full rundown, see our guide to the best Cloudflare settings for WordPress.

4. Verify Your DNS Records in Cloudflare

Go to DNS → Records and check the A record for your domain. It must point to your server’s current IP address — a wrong or outdated IP sends Cloudflare to a server that is not yours. Remove old or duplicate A records, and make sure the record is proxied (the orange cloud). DNS changes can take a few minutes to take effect, so wait briefly before retesting.

Network engineer checking server status and firewall settings to fix Cloudflare error 521

5. Pause Cloudflare to Test the Origin Directly

If the cause is still unclear, pause Cloudflare temporarily. In the dashboard, go to Overview → Advanced Actions and click Pause Cloudflare on Site. Visitors then reach your origin directly. If the site loads, the problem is in the Cloudflare-to-origin connection — the firewall or SSL mode above. If the error continues, the origin itself is down and the fix belongs to your host. Remember to unpause Cloudflare when you finish.

6. Contact Your Hosting Provider

If the server is running, the firewall is open and DNS is correct, ask your host. Tell them the exact time the error appeared and the Ray ID shown at the bottom of the error page. Hosts can check for rate limits on their edge, a crashed service on a shared node, or a network issue you cannot see.

Error 521 vs 522 vs 525

  • Error 521 — connection refused. The origin is down or blocking Cloudflare. Fix the server, the firewall or the ports.
  • Error 522 — connection timed out. Cloudflare reached the origin but got no response in time. See our guide to fixing Cloudflare error 522.
  • Error 525 — SSL handshake failed. The connection worked but the TLS handshake did not. See our guide to fixing Cloudflare error 525.

How to Prevent Error 521 in the Future

Set up uptime monitoring so you are alerted the moment the origin stops responding. Keep your server’s software updated and watch disk space and memory, since a full disk is a common silent killer of web services. Keep the Cloudflare IP allowlist in your firewall and re-check it after any firewall or server migration. Remove stale A records whenever you move hosts.

Conclusion

Cloudflare error 521 looks alarming, but it always has a concrete cause on the origin side. In most cases the fix is one of three things: restart a stopped web server, allowlist Cloudflare’s IP ranges in your firewall, or correct the SSL/TLS mode so it matches what your origin actually serves. Work through the steps in order and test after each one. If you run WordPress behind Cloudflare, our Cloudflare Tunnel setup guide is a good next read, and the free tools on KamiWeb can help you keep an eye on your site’s health.

Frequently Asked Questions

What does Cloudflare error 521 mean?

Error 521 means Cloudflare tried to connect to your origin server but the connection was refused, so it shows a “Web server is down” page. The origin is either stopped, blocking Cloudflare’s IP addresses, or not listening on the required port.

Can a visitor fix Cloudflare error 521?

No. A visitor cannot fix 521 because the fault is on the site owner’s server. Reload the page after a few minutes, and if the error stays, report the URL, the time and the Ray ID from the bottom of the error page to the site owner.

How do I allowlist Cloudflare IP addresses?

Get the current ranges from cloudflare.com/ips and add them to your server firewall, cloud security group and fail2ban’s ignoreip list. Also unban any Cloudflare addresses that fail2ban has already blocked.