Web Server Is Down Error Code 521: What It Means and How to Fix It
Web server is down error code 521 means Cloudflare could not connect to the website’s origin server at all. The full message reads “Error 521: Web server is down.” It appears when Cloudflare tries to reach the origin server and the server refuses the connection.
If you see error 521 as a visitor, the website is down, and there is very little you can do except wait and try again later. If you own the website, error 521 usually means your server is offline, your web server software has stopped, or a firewall is blocking Cloudflare. This guide explains what error 521 means, what causes it, and how to fix it step by step.
What Is Error Code 521?
Error code 521 is a Cloudflare-specific error. Cloudflare sits between visitors and a website’s origin server. When you visit a Cloudflare-protected site, your request goes first to Cloudflare, which then forwards it to the origin server.
Error 521 happens when Cloudflare tries to connect to the origin server on port 80 for HTTP or port 443 for HTTPS, and the connection is refused. The origin server may be offline, the web server software may have stopped, or a firewall may be blocking the connection. In all of these cases, Cloudflare has no website to show you, so it displays the 521 error page instead.
That is different from error 520, where Cloudflare connects to the server but gets an empty or invalid response. With error 521, there is no connection at all. For that related error, see our guide to Error Code 520.
What Causes Error Code 521?
1. The origin server is offline
The most common cause is simple: the server is down. It may have crashed, been restarted, run out of memory or disk space, or been taken offline by the hosting provider. If the server is not running, it cannot accept connections.
2. The web server software has stopped
Even if the server machine is on, the web server software, such as Apache or Nginx, may have stopped. A failed update, a configuration error, or a crash can stop the web server while the rest of the server keeps running.
3. A firewall is blocking Cloudflare
Firewalls, security plugins, and tools such as Fail2Ban can block Cloudflare’s IP addresses. If the firewall refuses connections from Cloudflare, the result is error 521, even though the site may load fine if you visit the server directly.
4. The wrong ports are closed
Cloudflare connects to the origin server on port 80 or 443. If those ports are closed, or if the web server is listening on a different port, Cloudflare cannot connect. This often happens after a server migration or a firewall change.
5. DNS points to the wrong server
If the site’s DNS records in Cloudflare point to the wrong IP address, Cloudflare will try to connect to a server that is not running a web server, or to a server that refuses the connection. This is common after moving to a new host without updating DNS.
6. The server is overloaded
A server under heavy load, or under a denial-of-service attack, may stop accepting new connections. Cloudflare’s requests are then refused, and visitors see error 521.
Error 521 vs Other Cloudflare Errors
| Error code | Meaning | Usual cause |
|---|---|---|
| 520 | Web server is returning an unknown error | Empty or invalid response from the origin server |
| 521 | Web server is down | Origin server refused the connection |
| 522 | Connection timed out | Origin server took too long to respond |
| 523 | Origin is unreachable | Cloudflare cannot route to the origin server |
| 524 | A timeout occurred | Origin server took over 100 seconds to respond |
Error 521 is the clearest of these errors: the server is down or refusing connections. That makes it easier to diagnose than error 520, because the fix is usually to get the server running again.
How to Fix Error Code 521 as a Visitor
As a visitor, you cannot fix the website’s server, but you can check a few things on your side.
Step 1: Refresh the page
Press F5, or Ctrl + R on Windows and Cmd + R on a Mac. The server may have been restarted, and a refresh a minute later may load the page.
Step 2: Wait and try again
Error 521 is often temporary. Wait ten to fifteen minutes and try again. Many server outages are fixed quickly by the site owner or hosting provider.
Step 3: Try a different browser or device
Open the same link in another browser, in a private window, or on your phone. If the site loads elsewhere, the problem may be with your browser cache or an extension, although this is uncommon for error 521.
Step 4: Check whether the site is down for everyone
Use a down-detector website to see whether other people can reach the site. If it is down for everyone, the problem is on the server side.
Step 5: Contact the website owner
If the error lasts for hours, contact the site through its social media accounts or support email. Tell them the exact page, the time you saw the error, and that it was error code 521.
How to Fix Error Code 521 as a Website Owner
If error 521 appears on your own site, work through these steps in order.
Step 1: Check that your server is online
Log in to your hosting account or server control panel and check the server status. If the server is offline, restart it. Check whether the hosting provider has reported an outage or maintenance.
Step 2: Check that the web server is running
Check that Apache, Nginx, or your web server software is running. Restart it if it has stopped, and check the error logs for the reason it stopped. A configuration error after an update is a common cause.
Step 3: Check ports 80 and 443
Make sure the web server is listening on ports 80 and 443, and that your firewall allows traffic on those ports. You can test this by visiting your site’s IP address directly, or by using a port-checking tool. If the ports are closed, open them in your firewall.
Step 4: Allow Cloudflare’s IP addresses
Make sure your firewall, hosting provider, and security tools allow Cloudflare’s IP address ranges. Cloudflare publishes a list of its IP ranges, and your server should allow connections from all of them. If you use Fail2Ban, ModSecurity, or a similar tool, check whether it has blocked Cloudflare.
Step 5: Check your DNS settings
In your Cloudflare dashboard, confirm that the DNS A record points to the correct origin IP address. If you recently changed hosts, update the record. Also check that the record is proxied through Cloudflare, with the orange cloud icon, if you want Cloudflare to handle the traffic.
Step 6: Check your SSL settings
If your site uses HTTPS, make sure the SSL certificate on your origin server is valid and covers your domain. In Cloudflare, the SSL mode should match your server: use Full or Full (Strict) if your server has a valid certificate. An SSL problem can also cause connection failures.
Step 7: Test with Cloudflare paused
In the Cloudflare dashboard, pause Cloudflare temporarily and visit your site directly. If the site loads with Cloudflare paused, the problem is in the interaction between Cloudflare and your server, most likely a firewall rule. If it still fails, the problem is on your server alone.
Step 8: Contact your hosting provider
If you cannot find the cause, contact your host with the error details and the time it happened. Ask them to check the server status, the web server, the firewall, and whether the origin server is refusing connections. A good host can usually identify a 521 cause quickly.
Common Problems and Fixes
Error 521 after a server move. Update the DNS records in Cloudflare to the new server’s IP address, and make sure the web server is running and ports 80 and 443 are open on the new server.
Error 521 only on HTTPS pages. Check the SSL certificate and the Cloudflare SSL mode. If the certificate has expired or is for the wrong domain, the connection will fail.
Error 521 after installing a firewall or security plugin. The new tool is probably blocking Cloudflare. Allow Cloudflare’s IP ranges in the firewall and in the plugin’s settings.
Error 521 at busy times. Your server may be running out of resources. Upgrade your hosting plan, enable caching, or optimise slow database queries so the server can handle the traffic.
Error 521 keeps coming back. A recurring 521 usually means the web server is crashing regularly, often because of a faulty plugin, a memory leak, or a server that is too small for the traffic. Fix the underlying cause rather than restarting the server each time.
For a related Cloudflare error, see our guide to Error 1015, and for general network checks, our guide to Netstat explains how to see which connections and ports your computer is using.
How to Prevent Error Code 521
Preventing error 521 is mostly about keeping your server healthy. Monitor your server’s uptime and set up alerts so you know immediately when it goes down. Keep your web server software and plugins updated, and test changes on a staging site first. Make sure your firewall always allows Cloudflare’s IP ranges, and keep your DNS records up to date when you change hosts. Finally, use a hosting plan with enough resources for your traffic, and enable caching to reduce the load on your origin server.
Frequently Asked Questions
What does web server is down error code 521 mean?
It means Cloudflare tried to connect to the website’s origin server and the connection was refused. The origin server is down, the web server software has stopped, or a firewall is blocking Cloudflare.
Is error 521 my fault as a visitor?
No. Error 521 is almost always a server-side problem. Visitors can refresh the page and wait, but only the website owner or hosting provider can fix it.
How long does error 521 last?
It depends on the cause. A brief server restart may cause error 521 for a few minutes. A firewall misconfiguration or a crashed server can cause it for hours until someone fixes it.
What is the difference between error 521 and error 520?
Error 521 means the origin server refused the connection, so the server is down. Error 520 means Cloudflare connected to the server but received an empty or invalid response. Error 521 is no connection; error 520 is a bad response.
Can I fix error 521 by clearing my cache?
Clearing your cache rarely fixes error 521, because the problem is on the server side. It is still worth trying a refresh and a different browser to rule out a local problem, but the permanent fix must be made by the site owner.
Conclusion
Web server is down error code 521 is a Cloudflare error that tells you the origin server refused the connection. For visitors, the best steps are to refresh the page, wait, and try again later. For website owners, the fix is usually to restart the server or web server software, open ports 80 and 443, allow Cloudflare’s IP addresses through the firewall, and check DNS and SSL settings. Keep your server monitored and your firewall rules up to date, and error 521 should stay away.