tutorials

How to Fix Error 521 with WordPress and Cloudflare

Share

Error 521 is a Cloudflare unique error message which occurs when you decline a connection with Cloudflare to the server on your WordPress site.

Basically, that indicates your web browser could connect to Cloudflare successfully, however, Cloudflare could not connect to the original web server – AKA the server on your WordPress website.

Cloudflare specifically tried to connect to the server of your WordPress website but received a rejected connection in reply.

Since Cloudflare cannot connect to your website, it cannot show a visitor to your website and instead displays the notice of Error 521. Error 520 is another common error for Cloudflare users.

What causes the message of Error 521?

Usually, one of two scenarios causes the Error 521 message:

  • First, it can be that the WordPress server site itself is down. Even if everything is properly configured, Cloudflare will simply not be able to connect if the server on your WordPress site is offline.
  • Second, your web server could work well, but for some reason, it will deny Cloudflare requests. Some server-side safety solutions might accidentally block the IP addresses of Cloudflare, because of how Cloudflare works.

Since Cloudflare is a reverse proxy, all traffic arriving at your server is shown to come from a small number of Cloudflare IPs (rather than the unique IP address of each individual visitor). Some security systems, therefore, consider and restrict high traffic from a small number of IP addresses. Cloudflare cannot connect if this occurs and instead displays the error message 521.

Here are the fixes for the error to ensure that you don’t get stuck with any hassles.

Fix 1: Search whether the server of your site is down

Server downtime among respectable companies is relatively uncommon. Many suppliers have virtually impeccable timings. So you can probably rule it out as the origin of error 521 unless you use an unreliable web host.

However, it is still a good idea, especially if you’re new to your current web hosting provider, to ensure this is not the problem. There are various ways to check and see if your site is online or if you cannot visit your website due to error 521. For instance, in the terminal, you may run a ping command, which works no matter which OS you are using.

The ping function performs an easy test to see if the server is accessible and ensure that you have no problems with connectivity. Follow the steps provided below to move ahead:

Step 1: Open the Windows PowerShell or command prompt.

Step 2: Type ping website name and press enter.

If you receive a server answer, it’s ready and accessible.

Fix 2: Whitelist all Cloudflare IP fields in the firewall of your server

The next fix is to Whitelist all the Cloudflare IP ranges, so you will ensure your server does not block them while your WordPress website’s server is working regularly. You’ll want to see that in .htaccess, iptables, or your firewall you don’t block these IP addresses.

You may already have observed that the .htaccess file has a lot to do with issues if you have previously tried to fix WordPress bugs.

The same goes for this. Here too, you can blame the .htaccess file. So we’ll examine how that problem can be resolved. We can’t just recreate the file and rectify the problems, unlike other errors. We must also do additional things here in order to make sure the file is correct.

The error 521 is not the cause of the corrupt .htaccess file. Therefore, the solution is different too. How can you repair that, we’ll see below.

Step 1: Go to your cPanel and then find the .htaccess file from there and open it.

Step 2: Paste the following command there, after replacing the ip address with your choice:

< RequireAny >

Require all granted

Require ip 127.0.0.1

< /RequireAny >

If you wish to whitelist multiple addresses, repeat the required ip line with the specified ip addresses.

You can try reloading the webpage to check whether it works, once you remove the blocking of IP addresses. It will certainly solve the problem.

Fix 3: Contact the Assistance

You can certainly call for assistance when nothing works, and look at what you have to say about it. Now, two possibilities are still available. You may be confused about contacting hosting support or contacting CDN assistance.

First, you can call the hosting aid and ask if or not there is a problem with the server. You can then contact the Cloudflare support staff if it does not function.

In most cases, the hosting problem is not Cloudflare. You should therefore initially contact the hosting assistance and then contact Cloudflare help if you have no solution to see what is happening there. Finally, you’ll certainly be able to find the solution to all the problems. You should therefore first make the tricks described above and you can contact support if nothing works.

Conclusion

Error 521 is usually found in your distribution of content when you initially integrate Cloudflare. Cloudflare accelerates websites, protects them against threats, and keeps them always online, making it easy to use web apps with a single click.

Cloudflare supports websites, no matter what the size or platform is, without the addition of any hardware, without installing any software or changing a line of code.

Chris Wagner

I am Chris Wagner, Having 12+ years of experience in the Hosting industry.

Published by
Chris Wagner

Recent Posts

9 Best Student Hosting for 2025

Hello, Gen Z! Ready to fly high with your dreams? Let no one stop you…

6 months ago

5 Best HideMyAss Alternatives (#3 is Just Awesome)

Let's talk about HideMyAss Alternatives! But first, let us talk about HideMyAss. If you’re interested…

6 months ago

Kadence WP Review (2025)

These days the theme market is flooded and users are spoiled by choices. But if…

6 months ago

10 Best Tested Video Hosting Sites

Thinking of starting a video log or want to host your video on a video…

6 months ago

9 Best Ecommerce Hosting Providers in 2025

So, you‘re looking for the best ecommerce hosting company for your needs? No matter whether…

6 months ago

Turnkey Internet Review: My Honest Opinion + Pros & Cons

Why Trust Us "We have been a paying customer for Turnkey Internet since March 2019.…

6 months ago