LocalHost.Co
error-codes

http error 521

Understand the HTTP Error 521 Web Server Is Down. Learn why Cloudflare fails to connect to the origin server and how administrators can troubleshoot firewall and routing issues.

21 Mar 2026

The http error 521, commonly accompanied by the message "Web Server Is Down," is a custom HTTP status code created by Cloudflare. When you browse the web and encounter this error, it signifies that Cloudflare's edge servers successfully routed your request to the website's designated origin server, but the origin server actively refused the connection. Essentially, the hosting server is saying, "I am here, but I will not allow you to talk to me."

Understanding the 521 Connection Refusal

To diagnose a 521 error, you must understand the TCP/IP handshake process. When Cloudflare tries to connect to the origin server, it sends a TCP SYN packet. If a 521 error occurs, the origin server responded with a TCP RST (Reset) packet, or it actively dropped the connection immediately after establishing it.

This is fundamentally different from a 522 Connection Timed Out. In a 522 error, the server doesn't respond at all. In a 521 error, the server does respond, but it forcefully rejects the connection attempt from Cloudflare.

Primary Causes of an HTTP 521 Error

Because the origin server is actively refusing the connection, the root cause almost always points to a firewall rule, a dead web server daemon, or strict security configurations on the hosting provider's side.

1. The Web Server Service is Down

The most literal cause of a "Web Server is Down" error is that the software responsible for handling HTTP requests (such as Apache, Nginx, or LiteSpeed) has crashed or was stopped. Even though the physical server machine is online and responding to network pings, there is no service listening on port 80 or 443 to accept Cloudflare's traffic.

2. Firewalls Blocking Cloudflare IPs

This is the most frequent cause for sites newly added to Cloudflare. Because Cloudflare acts as a reverse proxy, all traffic hitting your origin server comes from Cloudflare's IP addresses, not the actual visitors' IPs. A local firewall (like UFW or iptables) or a host-level security system (like Fail2Ban) might detect this massive volume of requests from a handful of IPs, incorrectly flag it as a Denial of Service (DoS) attack, and automatically block Cloudflare's IP ranges.

3. Poorly Configured Host Security Modules

Some hosting providers implement aggressive security modules (like mod_security or custom anti-bot scripts). If these scripts do not recognize Cloudflare's IPs as legitimate proxies, they will forcefully drop the TCP connection.

4. Changing Ports

Cloudflare only forwards traffic to a specific set of supported ports (like 80, 443, 8080). If your web server is accidentally reconfigured to listen on a non-standard port (like 3000) that Cloudflare doesn't support, the connection attempt on port 443 will be refused.

How to Troubleshoot and Fix an Error 521

Administrators need terminal or control panel access to their origin server to resolve this issue.

Step 1: Verify the Web Server is Running

Log into your origin server via SSH. Check the status of your web server service. For example, on an Ubuntu server running Nginx, type systemctl status nginx. If the service is dead or failed, restart it using systemctl restart nginx. Check the error logs if it refuses to start.

Step 2: Whitelist Cloudflare's IP Addresses

You must configure your firewall to implicitly trust all of Cloudflare's IP ranges. Cloudflare publishes a public list of their IPv4 and IPv6 ranges. If you use UFW (Uncomplicated Firewall), you must add an allow rule for each subnet (e.g., sudo ufw allow from 173.245.48.0/20 to any port 443). If your hosting provider has a visual security group firewall (like AWS EC2), ensure the rules allow inbound traffic on ports 80 and 443 from these ranges.

Step 3: Review Fail2Ban or Custom Security Scripts

If you are running Fail2Ban, check if any Cloudflare IPs have been jailed. You should configure Fail2Ban to ignore Cloudflare's IP ranges to prevent false positives.

Step 4: Verify the SSL Certificate on the Origin

While usually causing a 526, if you enforce strict SSL and the web server is configured to instantly drop connections that don't match its strict cryptographic requirements, a misconfigured certificate can sometimes manifest as a 521 connection refusal. Ensure your Nginx/Apache blocks are properly configured to listen on port 443 with a valid cert.

Frequently Asked Questions

Can a website visitor fix an Error 521?

No, this error implies a complete breakdown of communication between Cloudflare and the website's backend server. Only the server administrator can resolve it.

How is a 521 error different from a 502 Bad Gateway?

A 502 error means Cloudflare connected to the server, but the server returned invalid or garbage data. A 521 error means the server explicitly refused to even let Cloudflare connect in the first place.

Why does the site work perfectly when Cloudflare is paused?

If pausing Cloudflare fixes the site, it guarantees that your server's firewall is explicitly blocking Cloudflare's IP addresses. When paused, users connect directly to your server's IP, bypassing the Cloudflare network, which circumvents the firewall block.

Does a 521 error mean my site was hacked?

Not typically. It is almost always a configuration issue, a crashed service, or an overactive firewall rather than a malicious intrusion.

Reviews

No approved reviews yet.

Name, review, and a 5-star rating.
Showing approved comments for this article and language.

Related Articles

  • err_ssl_protocol_error

    Learn how to fix the err_ssl_protocol_error in your browser. This comprehensive guide covers common causes like date/time issues, cached data, and antivirus settings.

  • err_http2_protocol_error

    Encountering the err_http2_protocol_error? Discover the root causes behind this HTTP/2 connection failure and follow our detailed solutions to restore access.

  • err_quic_protocol_error

    Resolve the err_quic_protocol_error quickly with our step-by-step troubleshooting guide. Fix connection issues by disabling QUIC, resetting flags, or checking extensions.

  • ssl_error_bad_cert_domain

    Fix the ssl_error_bad_cert_domain warning by understanding why a website's SSL certificate domain doesn't match the URL you visited and how to bypass it safely.

  • ssl_error_no_cypher_overlap

    The ssl_error_no_cypher_overlap occurs when the client and server share no common encryption ciphers. Find out how to update protocols and bypass this barrier safely.

  • ssl_error_rx_record_too_long

    Struggling with ssl_error_rx_record_too_long? Learn how to fix this Firefox-specific secure connection error caused by server misconfigurations or port conflicts.

  • whea_uncorrectable_error

    A whea_uncorrectable_error is a serious hardware BSOD in Windows. Read our guide to diagnose CPU, RAM, or voltage issues and restore system stability permanently.

  • dxgi_error_device_removed

    Fix the dxgi_error_device_removed crash. Find out why your system thinks the graphics card was physically removed and how to resolve driver and power supply issues.