Your Dedicated Partner for All Things WordPress

How to Fix Cloudflare Error 521 in WordPress?

Table of Contents

Cloudflare sometimes gives you errors that become hard to solve. One of the errors that you might come across is Cloudflare error 521 in WordPress. We will see the overview of the error and how to fix Cloudflare error 521 in WordPress.

Overview of Error 521

How to Fix Error 521 in WordPress?

Cloudflare is a CDN that will allow you to increase the security and performance of your website. So, you surely might be using it.

What if you come across any error? You surely wouldn’t know how to solve it. Therefore, we will see how you can solve it.

Before that, we will see why you face this error. It is not specifically for Cloudflare, it can also be for the webserver.

It means that when the request was sent to Cloudflare and when Cloudflare sent a request to the server but was unable to connect. When the server didn’t respond, it shows you the error.

The next reason for the error might also be Cloudflare’s issue. For example, if your WordPress website is blocking Cloudflare’s requests then you will see this error.

So, it can be Cloudflare’s fault or it can also be the server’s fault. We will see how you can fix it.

Fix Cloudflare Error 521 in WordPress

Here are few ways to check fix Cloudflare error 521 in WordPress. We will see the steps on how to do it.

Check the Webserver

The first issue might be from the webserver. So, you need to see whether the webserver is working or not. If the webserver is not working, you will see this error. Therefore, you will have to check the webserver first.

There are many ways to do it. If you have multiple websites hosted on your server, you can check other websites to see if it is working or not. Alternatively, you can also check the status page of your hosting provider. Generally, they have all the data shown over there. So, if one of their servers is not working properly, you will see the information right there. This will give you an idea of whether the webserver is down or the CDN is at fault.

In some web hosts, you will also see the option to test the webserver. You can test the webserver with that.

For example, if you are using Kinsta, you can see the IPV4 DNS used. Once you have the IP address, you can run a header request test to find out whether there is a response or not.

In the same way, most of the managed hosting or VPS/Dedicated server gives you the option to check the website. You can also check the same thing with the terminal. However, this is for advanced users.

If you are not aware of any of these things, you can contact the live chat and ask them if something is wrong with their server (you can read this complete article before contacting them).

Change HTTP to HTTPS

Cloudflare activates the SSL certificate. Let’s understand this in deep.

When you don’t have an SSL certificate, the website will redirect all the HTTP requests. Even if you write HTTPS://example.com, it will be redirected to http://example.com. That’s because of the protocol.

Now, when you activate the SSL, Cloudflare redirects the websites to HTTPS. However, if the actual domain in your WordPress is set to HTTP, it will be an endless loop. Cloudflare will try to redirect the URL to HTTPS whereas the website will try to redirect the URL to HTTP. Therefore, you will see the error.

The easiest way to fix this is by changing the HTTP to HTTPS. To change it, you can go to the WordPress settings. In general settings, you will see the option to change the URL. Change the URL and reload the page. Just changed the HTTP to HTTPS on the settings page.

Now, you can try reloading the website again to see if it is working or not. In most cases, you will see the website will be running.

If not, make sure that you don’t have the redirection plugin that is giving an issue. If there is a redirection plugin installed, it might be giving issues. You can try deactivating it to see if the plugin is the issue or not. If the plugin is the issue, you can try deactivating it and see it again.

Change Full SSL to Flexible SSL

Cloudflare has various options that you can use when it comes to the SSL certificate. The two options that you can choose from the full SSL and the second one is the flexible SSL. Along with these, there are various other options too. Right now, we will only consider these two to make things easier and faster. You can then mess around with the options to see which one works best for you.

In most cases, this error occurs when you are using full SSL. So, you can simply change the SSL certificate to flexible instead of full.

The option can be accessed by following the below steps.

  • You will have to first log in to the dashboard
  • You can then select the crypto option in the menu tabs. That would be the 4th
  • Have a look at the sidebar and you will see the option to select the SSL
  • Change the SSL certificate from full to flexible
  • Wait for it to get activated
  • Try loading the website again to see if it has worked or not.

Alternatively, if you have the Cloudflare WordPress plugin installed on your website. You can also change things from there. If you haven’t yet installed it, you can install Cloudflare Flexible SSL from the WordPress plugin directory. It will help you to solve the error. Therefore, you can also use the plugin if you don’t want to visit the official website too often. The plugin helps you to do a lot of things. Most of the configuration options are directly accessible there.

The .htaccess File

If you have already tried to fix WordPress errors before, you might have noticed that the .htaccess file has a lot to do with the errors.

The same thing applies here. Even here, the .htaccess file can be the culprit. So, we will see how you can fix that issue.

Unlike other errors, we can’t just regenerate the file and fix the errors. Here, we also need to do other things to make sure that the file is proper.

The corrupt .htaccess file is not the reason for error 521. So, the solution is also different. We will see how you can fix it.

Open the .htaccess file. Here are the steps to open it.

  • You can open the file manager from cPanel.
  • Inside it, you will see the .htaccess file. If not, you can go to settings from the top menu. Click on the settings and then you can select “Show hidden files”.
  • When you click on the Show hidden files option, you will see the .htaccess file option.
  • Now, open the file. You can click on the code edit button. Then you see the file editor.

You will have to make sure that there are no IP addresses blocked. You can confirm that the IP addresses from cloudflare.com/ips. Make sure that none of the IP addresses are blocked which are from this list.

If the .htaccess file is blocking any of the IP addresses, you will need to remove the blocking.

Once you remove the blocking of the IP addresses, you can try reloading the website to see if it is working or not. It will surely fix the issue.

Contact the Support

If nothing works, you can surely contact the support and see what they have to say on this.

Now, you have still got two options here. You might be confused about whether to contact hosting support or you should contact CDN support. Quite a confusion, right? Here is the solution to that too.

You can contact the hosting support at first and ask if something is an issue with the server or not. If it doesn’t work, you can then contact the support team of Cloudflare.

In most cases, the issue will be with the hosting and not Cloudflare. Therefore, you should first contact the hosting support and then if don’t have a solution, you can contact Cloudflare support to see what’s wrong there.

In the end, you will surely get the solution to all the problems. Therefore, you should first do the above-given tricks and if nothing works, you can contact support.

Final Words

To conclude, these are some of the ways to fix Cloudflare error 521 in WordPress with ease. If you are making changes in the .htaccess file, make sure you have a backup of the file. So, if something goes wrong, you can restore the file with just a few clicks. In the same way, make sure you have the support pin handy when you are contacting the support. They will ask for it.

How to get started?

Learn more

WordPress Maintenance

Save 33% with our Annual pricing plan.

Get Started

Looking for help? Chat with us.

Are you in need of assistance or guidance? Look no further! Our dedicated team is here and ready to help. Chat with us today and let’s work together to find the perfect solution for your needs.

Our support team will get you:

I believe every website owner deserves a reliable professional support always by their side.

Alexey Seryapin
Founder of WPServices

Having Troubles With WordPress?

Claim Your Free WordPress Maintenance

In today’s fast-paced digital landscape, every website deserves the care and expertise of a professional maintenance team, ensuring optimal performance, enhanced security, and seamless user experiences, so you can focus on growing your business with peace of mind.

Alexey Seryapin
Founder of WPServices

Coupon Code Applied!

Take your time and continue browsing our services.

Alexey Seryapin
Founder of WPServices