Error 521 is a Cloudflare-specific error message (similar to Error 520) when your WordPress websiteThis error occurs when the server rejects the connection to Cloudflare.
![图片[1]-解决 Error 521 错误:Cloudflare 连接被拒绝的原因与修复方法](https://www.361sale.com/wp-content/uploads/2024/12/20241217095914128-image.png)
What is Error 521 Web Server Shutdown?
As mentioned above, the Error 521 error is a Cloudflare-specific error message.
Basically, it means that your web browser is able to successfully connect to Cloudflare, but Cloudflare is unable to connect to the source web server - the server where you host your WordPress website.
Specifically, Cloudflare receives a Connection Denied error response when trying to connect to your WordPress web server.
Since Cloudflare is unable to connect to your site, it is unable to display your site to visitors and therefore displays the Error 521 error message.
![图片[2]-解决 Error 521 错误:Cloudflare 连接被拒绝的原因与修复方法](https://www.361sale.com/wp-content/uploads/2024/12/20241217094202303-image.png)
Causes of Error 521 error message
Typically, Error 521 errors are caused by one of the following:
1. Your WordPress web server may be down!. Even if everything else is configured correctly, if your WordPress web server is offline, Cloudflare cannot connect to it.
2.Your web server may be running fine, but for some reason is blocking Cloudflare requests. Because of the way Cloudflare works, some server-side security solutions may accidentally block Cloudflare's IP address.
Because Cloudflare is a reverse proxy, all traffic to your origin server appears to come from a small range of Cloudflare IPs (rather than each visitor's unique IP address). As a result, some security solutions will treat high traffic from a small number of IP addresses as an attack and block it.
When this happens, Cloudflare will fail to connect and display an Error 521 error message.
How to Fix Cloudflare and WordPress Error 521
Now that we know why, the problem is solved!
Step 1: Test if the source server is online
Before proceeding, make sure your WordPress web server is online and functioning properly. If the server is unavailable, there is no point in continuing with the troubleshooting process.
To test this, run a cURL command. If you are using a Mac or Linux, you can run the command directly from the terminal.
Windows systems do not have cURL installed by default, and while it is possible to install it manually, a simpler way is to use the Online HTTP Header Inspection Tool provided by KeyCDNThe
Simply enter http://1.2.3.4, where 1.2.3.4 is the actual IP address of your server.
![图片[3]-解决 Error 521 错误:Cloudflare 连接被拒绝的原因与修复方法](https://www.361sale.com/wp-content/uploads/2024/12/20241217094817988-image.png)
If there is a problem with the server, but you are not sure what is happening, it is best to contact the server merchant to resolve the issue.
Step 2: Whitelist all Cloudflare IP ranges in the server firewall
If your WordPress web server is working fine but you still see the Error 521 error message when accessing your website, the next step is to whitelist all Cloudflare IP ranges to make sure that your server isn't blocking those IPs.
These are the full list of IP ranges for Cloudflare.
![图片[4]-解决 Error 521 错误:Cloudflare 连接被拒绝的原因与修复方法](https://www.361sale.com/wp-content/uploads/2024/12/20241217100556369-image.png)
Need to make sure that these IP addresses are not blocked in .htaccess, iptables or firewalls. Also need to make sure that your server provider is not rate limiting or blocking requests from Cloudflare IP addresses.
Step 3: Consider more specific issues
Finally, here are some more specific technical steps that can be handled depending on the configuration of the server.
1. If you are just starting to use Cloudflare's HTTPS, your source server may not be configured to allow Cloudflare's IP address to access the 443 ports. If you cannot configure your firewall to allow this, try using Flexible SSL instead of Full SSL in Cloudflare.
2. Make sure you are using the latest version of Bad Behavior or mod_security (if applicable).
3. If you are using the mod_antiloris or mod_reqtimeout Apache modules, disable and uninstall them.
reach a verdict
If you still encounter Error 521 error after making these adjustments, it is best to contact your server provider to fix the problem for you most conveniently and quickly. Other than that, take a look at our other articles -How to set up Cloudflare free CDN in WordPressThe
Link to this article:https://www.361sale.com/en/30793The article is copyrighted and must be reproduced with attribution.
No comments