Cloudflare Error 521 (Web Server Is Down): Causes and How to Fix It
What Is Cloudflare Error 521?
Cloudflare Error 521 (Web Server Is Down) indicates that Cloudflare successfully routed traffic to your origin IP address, but the origin web server explicitly refused the TCP connection on port 80 or port 443.

This error differs from timeout-based responses like Cloudflare Error 522 (Connection Timed Out) or gateway timeouts like Cloudflare Error 524 (A Timeout Occurred). In an Error 521 scenario, the network route is open, but no listening process accepted the proxy connection or an origin security mechanism sent an active TCP rejection (RST packet).
Primary Causes of Error 521
According to Cloudflare Support documentation, HTTP 521 errors stem from origin-side configurations and runtime issues:
- Web Server Offline or Crashed: The web daemon running on the host (such as Apache, Nginx, or IIS) is stopped, unresponsive, or experiencing process crashes.
- Blocked Cloudflare IP Ranges: Origin firewalls, iptables, intrusion prevention systems (fail2ban), or hosting security modules misidentify reverse proxy traffic as an attack and actively block or rate-limit Cloudflare IP addresses.
- SSL/TLS Configuration Mismatch: If your Cloudflare SSL/TLS encryption mode is set to Full or Full (Strict), Cloudflare attempts to connect via port 443. If your origin server does not have an active SSL/TLS certificate (such as a Cloudflare Origin Certificate) or is not listening on port 443, the connection is refused.
Diagnostic Steps: Testing Direct Origin Response
Before adjusting firewall configurations or changing hosting plans, run direct diagnostic commands to isolate whether the issue originates from the web daemon or network filtering.
Bypass Cloudflare Proxy via cURL
Test whether your origin server accepts direct connections on standard HTTP and HTTPS ports by targeting your origin server IP address directly while preserving your domain header:
curl -I -H 'Host: example.com' http://YOUR_ORIGIN_IP
curl -I -H 'Host: example.com' https://YOUR_ORIGIN_IP -k
Replace example.com with your zone name and YOUR_ORIGIN_IP with your actual server IP. If the direct HTTP query returns a connection refused error, your web server service is not actively listening on port 80. If HTTPS fails while HTTP succeeds, port 443 or SSL/TLS listeners are misconfigured.
How to Resolve Cloudflare Error 521
1. Verify Origin Web Service Status
Check the active status of your web server daemon. Review server system logs to verify if service crashes or memory exhaustion forced the process offline. Ensure the service starts automatically on system reboots.
2. Allow Cloudflare IP Addresses in Origin Firewalls
Because Cloudflare operates as a reverse proxy, all proxied visitors connect through Cloudflare edge IP addresses. If your origin hosting provider or local firewall enforces rate limits or blocks these addresses, legitimate traffic is rejected.
Explicitly allow all official Cloudflare IPv4 and IPv6 address ranges across host-level firewalls, security plugins, and hosting control panel security layers.
3. Match Cloudflare SSL/TLS Modes to Server Capabilities
Ensure that the encryption settings selected in your Cloudflare dashboard correspond with your host listening ports:
- Flexible: Connects to the origin over plaintext HTTP on port 80.
- Full or Full (Strict): Requires the origin server to actively listen on port 443 and serve a valid SSL/TLS certificate.
If changing encryption modes triggers redirection issues, consult guidance for resolving Cloudflare ERR_TOO_MANY_REDIRECTS.
Verification Steps
Once you have adjusted origin service processes, firewall rules, or SSL certificates, verify that the error is resolved:
- Execute direct cURL queries against the origin IP to verify clean 200/300-series HTTP status codes without connection refusal errors.
- Purge the Cloudflare edge cache in your dashboard under Caching to clear any cached error responses.
- Open your domain in a private browsing window to verify normal page delivery.
Information to Provide Your Hosting Provider
If the error persists after confirming server processes and firewall configurations, contact your hosting support team. As outlined in Cloudflare 5xx troubleshooting guidance, provide the following details:
- The specific error code (Error 521: Web Server Is Down).
- The exact timestamp and timezone when the connection refusal occurred.
- The specific URL that returned the 521 error.
- Logs from any load balancers, local security software, or intermediate proxies situated in front of your web server.