How to Fix Cloudflare Error 521 in WordPress: Simple Solution

This error will only occur in the Cloudflare service that uses theWordPresswebsite, an error occurs when the server-side connection times out. This means that Cloudflare cannot connect to the original server.

Downtime costs can be high. While the cost of downtime varies from industry to industry, it's a loss that can't be ignored. But don't worry, fixing "Error 521: Web server is down"It's not too complicated.

Image [1] - How to Fix and Prevent Cloudflare Error 521: Detailed Guide

Fix Cloudflare Bug 521

What is error 521?

As mentioned, when Cloudflare When you can't connect to the site's serverWhen this happens, site visitors see the following error message:

Image [2] - How to Fix and Prevent Cloudflare Error 521: Detailed Guide

Many people's first reaction is that something is wrong with Cloudflare, but it's not. The problem is on the side of the server where your website is hosted. Visitors to your site can accessCloudflare's serversBut Cloudflare can't access your side of the server.

Why do websites using Cloudflare get Error 521?

Error 521 is a common error that can cause Cloudflare to fail to deliver website content properly to visitors. Below are the main reasons that may cause this error and their solutions:

1. Overloaded or under-resourced servers

  • rationale: The server is overstressed by a surge in traffic, or runs out of memory, storage, or other resources, and is unable to respond to Cloudflare requests in a timely manner.
  • prescription: Select a company that hasAutomatic Expansionrespond in singingload balancingManaged services with features such as Cloudways Autonomous to handle traffic spikes.

2. Servers offline

  • rationale: Server downtime is one of the direct causes of Error 521.
  • prescription: Ensure the use of high-availability hosting services, such as those that provide99% Uptime GuaranteeCloudways.

3. DNS misconfiguration

  • rationale: Configuring Cloudflare can result in a 521 error if the DNS settings are incorrect or have not yet propagated completely (usually takes 24-48 hours).
  • prescription: Using a program like DNS Made Easy Such a service can reduce the dissemination time to less than 2 hours.

4. Firewall blocking Cloudflare

  • rationale: Server firewalls may misidentify Cloudflare requests as malicious traffic and block connections.
  • prescription: Check the server's firewall rules to make sure that Cloudflare's IP address is allowed through.

5. Cache data conflicts

  • rationale: Conflicting or outdated data cached by the server may prevent normal communication with Cloudflare.
  • prescription: Clean server cache to ensure data consistency.

How to Fix Cloudflare Error 521 in WordPress

Error 521 can be caused by a variety of reasons. So let's take a look at some of the most common causes and see how you can fix them to solve the problem.

To resolve error 521, access your web server and Cloudflare. the specifics depend on which cloud provider's servers you're using.

 Verify that the site is online

This is the basics. If the server is down, you will definitely encounter a 521 error. As said before, when a 521 error occurs, visitors to your website can access the Cloudflare server, but Cloudflare cannot access your server.

When Cloudflare is implemented on a website, it acts as a reverse proxy, which means that visitors to the website first arrive at Cloudflare's servers and then go to the website. Think of it as a bridge between the two.

To check if the server is running, simply ping it. You can check if the server is running by pinging it with theterminal and runPing command, as shown below:

Image [3] - How to Fix and Prevent Cloudflare Error 521: Detailed Guide

In this example, using the Ping command, 4 packets were sent and 4 packets were received, which indicates that the server is operational.

It is also possible to useCurlcommand to get a status response from the server. If theHTTP Status Codesbecause of200If not, this is a 521 error. If not, this is a 521 error.

This is the command that should be run:

<strong>curl -silent -output /dev/null -write-out "%{http_code}" https:// examplewebsite.com</strong>
<strong>curl -silent -output /dev/null -write-out "%{http_code}" https:// examplewebsite.com</strong>
curl -silent -output /dev/null -write-out "%{http_code}" https:// examplewebsite.com

If you don't want to run the Curl command and prefer to use an online tool to check the status of the server, use theHTTP Header CheckerThat's all.

Image [4] - How to Fix and Prevent Cloudflare Error 521: Detailed Guide

If you receive an HTTP status code5xx, then it indicates an error on the server. For example, if you see301maybe403status codes, then don't worry about them because they don't indicate that the server is down.

Whitelist Cloudflare IP addresses in .htaccess files or server settings

Blacklisted IPs also prevent Cloudflare from accessing the web server. If Cloudflare is unable to redirect incoming requests to the web server (because its IP is blacklisted), this may result in a 521 error.

Whitelisting IPs is also relatively simple. You need to edit the .htaccess fileand add Cloudflare's IPV4 and IPV6 IPs.

Establishment with the serverAfter the SFTP connection, I usedFileZillaAccess my .htaccess file. The .htaccess file can be found here:/applications/mamxbvhtce/public_htmlThe

Place this [ mamxbvhtce ] to your application name.

Access the .htaccess file and add the following code:

order deny, allow
deny from all
order deny, allow
deny from all
order deny, allow deny from all

After adding the code, paste Cloudflare's IPs and before each IP add " allow from". canhereFind the IP of Cloudflare.

Like this:

order deny, allow
deny from all
allow from 103.21.244.0/22
allow from 103.22.200.0/22
allow from 103.31.4.0/22
allow from 104.16.0.0/13
allow from 104.24.0.0/14
allow from 108.162.192.0/18
allow from 131.0.72.0/22
allow from 141.101.64.0/18
allow from 162.158.0.0/15
allow from 172.64.0.0/13
allow from 173.245.48.0/20
allow from 173.245.48.0/20 allow from 188.114.96.0/20
allow from 190.93.240.0/20
allow from 197.234.240.0/22
allow from 197.234.240.0/22 allow from 198.41.128.0/17
allow from 2400:cb00::/32
allow from 2606:4700::/32
allow from 2803:f800::/32
allow from 2405:b500::/32
allow from 2405:8100::/32
allow from 2a06:98c0::/29
allow from 2c0f:f248::/32
order deny, allow
deny from all
allow from 103.21.244.0/22
allow from 103.22.200.0/22
allow from 103.31.4.0/22
allow from 104.16.0.0/13
allow from 104.24.0.0/14
allow from 108.162.192.0/18
allow from 131.0.72.0/22
allow from 141.101.64.0/18
allow from 162.158.0.0/15
allow from 172.64.0.0/13
allow from 173.245.48.0/20
allow from 173.245.48.0/20 allow from 188.114.96.0/20
allow from 190.93.240.0/20
allow from 197.234.240.0/22
allow from 197.234.240.0/22 allow from 198.41.128.0/17
allow from 2400:cb00::/32
allow from 2606:4700::/32
allow from 2803:f800::/32
allow from 2405:b500::/32
allow from 2405:8100::/32
allow from 2a06:98c0::/29
allow from 2c0f:f248::/32
order deny, allow deny from all allow from 103.21.244.0/22 allow from 103.22.200.0/22 allow from 103.31.4.0/22 allow from 104.16.0.0/13 allow from 104.24.0.0/14 allow from 108.162.192.0/18 allow from 131.0.72.0/22 allow from 141.101.64.0/18 allow from 162.158.0.0/15 allow from 172.64.0.0/13 allow from 173.245.48.0/20 allow from 173.245.48.0/20 allow from 188.114.96.0/20 allow from 190.93.240.0/20 allow from 197.234.240.0/22 allow from 197.234.240.0/22 allow from 198.41.128.0/17 allow from 2400:cb00::/32 allow from 2606:4700::/32 allow from 2803:f800::/32 allow from 2405:b500::/32 allow from 2405:8100::/32 allow from 2a06:98c0::/29 allow from 2c0f:f248::/32

Add it later:</IfModule>

Image [5] - How to Fix and Prevent Cloudflare Error 521: Detailed Guide

Since the IP will not be blacklisted, this method will also resolve the 521 error.

Check your firewall settings to make sure Cloudflare is not blocked

Firewalls or IP Interceptors may also be the cause of the error. You can go toFirewall SettingsincludeWhitelisted IP addresses for CloudflareReady to go.

Image [6] - How to Fix and Prevent Cloudflare Error 521: Detailed Guide

If you are using a web host that offersCpanelThe company can check itsIP Blockerfunction, make sure that no IP address of Cloudflare is added to it. If Cloudflare's IP is not blocked, you will not encounter the 521 error.

Disable the security plugin (if it conflicts with Cloudflare)

plug-ins may also cause error 521. firewall-enabledWordPress Security Pluginmay conflict with Cloudflare, preventing it from accessing the web server.

For example, Wordfence may conflict with Cloudflare. Temporarily disable the WordPress plugin and check if the error disappears.

Checking Cloudflare's Security Settings

Turning Cloudflare security too high can also cause a 521 error. To determine if this is causing the error, turn it down to"Medium."maybe"Low.", and then try to access the site again.

To access Cloudflare's security settings, go to "Security."tab or click thehere (literary)Direct access to security settings.

Image [7] - How to Fix and Prevent Cloudflare Error 521: Detailed Guide

Check the Cloudflare DNS settings to make sure they are configured correctly

If the DNS records are not configured correctly, this definitely indicates the reason for the 521 error on the website. To verify if this is the root cause of the error, log into your Cloudflare account and go to theDNS Settings PageThe

strike (on the keyboard)record (in sports etc)probeA Recordsmatches the IP address of your source server. In addition, make sure that theCNAME recordsContains your website domain name.

Image [8] - How to Fix and Prevent Cloudflare Error 521: Detailed Guide

Install a valid SSL certificate on the source web server

When configuring Cloudflare on a site, one of the settings to configure for managing security preferences is theSSL/TLS. Among the various SSL/TLS modes offered, if you select theComplete (strict)Cloudflare performs authentication checks between its edge servers and servers.

Image [9] - How to Fix and Prevent Cloudflare Error 521: Detailed Guide

If the server's SSL Certificatehas expired or does not match the website domain, Cloudflare will block the SSL connection, resulting in a 521 error.

In the case above, the free Let's Encrypt SSL certificate has been installed on the host machine, and selecting the"Complete."Instead of "full (strict)" as the current encryption mode.

Image [10] - How to Fix and Prevent Cloudflare Error 521: Detailed Guide

However, if set to "Complete (strict)", then the solution would be to install theCloudflare Origin CertificateTo obtain an Origin certificate, go to To obtain an Origin certificate, go toSSL/TLS > Origin server > Create certificateThis will also resolve the 521 error. This also resolves the 521 error.

Image [11] - How to Fix and Prevent Cloudflare Error 521: Detailed Guide

Disable mod_reqtimeout and mod_antiloris on the web server.

Apache modules such asmod_reqtimeoutrespond in singingmod_antiloris)It's after passing theRestrict the way client connections interact with the server to preventDoSrespond in singingDDoStarget. These modules manageConnection timeoutand from a single IPConcurrent connectionNumbers.

If these modules are configured on an Apache server, compatibility issues with Cloudflare may arise.Cloudflare acts as a proxy for the(math.) genusForwards client traffic to your server using its own IP. the Apache module can treat legitimate requests from Cloudflare as atimeout violationor from a single IPsuccessive connection attempts, thereby blocking them.

If this is encountered, the IP address of Cloudflare must be whitelisted. In addition, the module settings on the Apache server must be adjusted. For example.Adding a timeout limitThe

Clear the server cache to resolve any conflicts caused by outdated data

I mentioned this at the beginning of the article because I can emphasize how simple and effective this troubleshooting step is in resolving the 521 error.

Clearing your server's cache ensures that new requests from Cloudflare can access your server. Outdated requests may cause a mismatch that triggers a 521 error.

To clear the cache, simply log into the server administration panel and clear the cache. Clearing the cache is not a direct solution to the error, but it helps ensure that Cloudflare receives the most up-to-date response from your server.

Disable Cloudflare and check for other website issues

If you have tried everything and nothing works, you can temporarily disable Cloudflare to see if that solves the problem. Check for otherCommon WordPress ErrorsIf you do, see if you can resolve the 521 error.

Check the WordPress logs to find out the exact cause of the problem. Once you have identified the issue and fixed everything, enable Cloudflare again and check if the 521 error still exists.

reach a verdict

Resolving Cloudflare error 521 is not difficult as long as you can troubleshoot the cause of the problem.

Attention:When Cloudflare tries to pass the port80maybe443A 521 error occurs when you access your original server but receive a connection refused error.

Also check out our article How to set up Cloudflare free CDN in WordPress

Image [12] - How to Fix and Prevent Cloudflare Error 521: Detailed Guide

common problems

Question 1. Is error 521 a common problem for Cloudflare users?

Yes, Error 521 is a common error for websites using Cloudflare CDN. This error occurs when Cloudflare cannot access your source server.

Q2. Does error 521 affect SEO?

Yes, Error 521 can be devastating to a website's SEO as the website is practically down. Regardless of the cause of the 521 error, if the site is inaccessible, it can damage the site's search rankings, and user experience.

How can I prevent Error 521 from happening again?

To prevent the 521 error from happening again, you must ensure that the server is always up and running. In addition, make sure that the server is configured correctly to handle Cloudflare requests. The server error can be effectively avoided if you monitor the server's operation and adjust the server's firewall settings from time to time.


Contact Us
Can't read the article? Contact us for free answers! Free help for personal, small business sites!
Tel: 020-2206-9892
QQ咨询:1025174874
(iii) E-mail: info@361sale.com
Working hours: Monday to Friday, 9:30-18:30, holidays off
© Reprint statement
This article was written by Banner1
THE END
If you like it, support it.
kudos101 share (joys, benefits, privileges etc) with others
commentaries sofa-buying

Please log in to post a comment

    No comments