How to Fix It for WordPress Websites

Have you stumbled upon the Cloudflare error 521? 🤔

The 521 is a common Cloudflare error and it typically appears on a WordPress website when Cloudflare fails to connect with the site’s server. This can happen either because your site’s hosting server is down or blocking Cloudflare’s IP addresses. Other causes, such as misconfiguration or software issues, could also occur.

In this article, we will show you how to remove the error and get your website up and running in no time. But before you implement the solutions, let’s take a quick dive into the causes of the Cloudflare 521 error.

Let’s get started.

📚 Table of contents:

  1. Check if your web server is down
  2. Whitelist Cloudflare IP ranges
  3. Choose the proper Cloudflare encryption mode
  4. Seek help from the hosting provider or Cloudflare support

What causes Cloudflare error 521?

To understand the causes, you need to first have a clear picture of how the Cloudflare CDN works.

Cloudflare error 521.

One of Cloudflare’s main responsibilities is to improve the performance of a website.

To that end, it caches and serves static content from its global network of servers, helping reduce the load on the web server and boosting site speed in the process.

As you can imagine, the CDN needs to connect with your site’s web server during the caching process (although such connections are not limited to the caching process alone).

While making such connections Cloudflare may encounter problems like the site’s hosting server going down or the CDN being blocked from accessing the site because it’s viewed as a security threat.

Why is your site’s hosting server down?

Your site’s web server can be down due to reasons like hardware failure, software issues, scheduled maintenance, security breaches, and misconfigurations, among other things. More on this in the “how to fix” section.

Why is Cloudflare seen as a security threat?

Besides improving the site speed, Cloudflare is also responsible for improving your site’s security.

To protect a WordPress website against security threats, the CDN examines all incoming requests and identifies and blocks malicious traffic from accessing your site.

Since all your traffic passes through Cloudflare’s network before reaching your hosting server, the CDN can be viewed as hiding the true origin of your site’s traffic.

This is suspicious behavior and it causes many hosting servers as well as some security plugins to prevent Cloudflare from accessing your website, leading the CDN to trigger the 521 error.

Now that you know the real cause of the Cloudflare error 521, let’s dive into the steps you need to take to remove it from your WordPress site. 🤿

How to fix Cloudflare error 521 on a WordPress website?

👉 To remove the Cloudflare error 521 from your WordPress website, you need to take the following steps:

  • Check if your web server is down
  • Check encryption settings
  • Whitelist Cloudflare IP ranges
  • Ensure Cloudflare can connect to port 443

You don’t need to implement all the steps in one go. Implement one at a time and then check whether the error is gone from your website.

Important: Clear cache and check site

In the previous section, we touched upon how caching is used by Cloudflare to serve static content to your visitors as a way to reduce the loading speed of your website.

Like the CDN, browsers also use caching to load web pages faster.

The problem is that browsers can end up caching the site when it’s showing error messages. They might keep displaying that cached page even when the error is gone from the site.

We recommend that you remove your browser cache and make sure that the 521 Cloudflare error cache is not a temporary glitch.

1. Check if your web server is down

The easiest method of verification is to get on a live chat with the support team of your hosting provider and seek information about web server outages.

If live chat is not an option, then there are a few other ways to find out whether your web server is down.

When web servers undergo scheduled maintenance or an outage, they send emails informing customers about it. We recommend checking your email and looking for messages from your hosting provider.

Bluehost server down maintenance email.

Alternatively, you can also use tools like “down for everyone or just me,” and “is it down right now,” “down detector,” to check if your hosting server is offline. There is also a website monitoring tool such as UptimeRobot.

Some hosting providers post updates on server outages on a dedicated status page. You might want to look for that. Also, try checking your hosting provider’s social media handles for any news on server outages.

If your hosting server is down, then there is nothing you can do other than urge your hosting provider to get it up and running as quickly as they can.

But if your hosting server is not causing the Cloudflare error 521, proceed with the next solution.

2. Whitelist Cloudflare IP ranges

Since hosting servers and security plugins are known to block Cloudflare IP addresses, whitelisting Cloudflare IP ranges could help remove the 521 error from your WordPress site.

💡 We suggest seeking help from your hosting provider to implement whitelisting.

If you prefer whitelisting manually, then we have a separate guide on whitelisting for that. It involves going to the backend of your site and adding a code snippet along with the Cloudflare IP ranges to an important WordPress file. Needless to say, this is risky business! So if you are going the manual way, just be sure to take a backup of your website.

Another way of whitelisting manually is by using a security plugin that offers an option for whitelisting IP addresses.

For instance, MalCare Security Plugin records every IP address blocked by its firewall and offers an easy way to whitelist those IP addresses. But you need to make sure that you are whitelisting the correct ones. If you are unsure about which IP addresses to whitelist, it’s best to seek help from your hosting provider.

Whitelisting IPs in Malcare.

3. Choose the proper Cloudflare encryption mode

Cloudflare uses encryption modes to establish a secure connection between the CDN and your web server. The CDN has three encryption modes: flexible, full, and full (strict).

The full modes are the safest and the most popular encryption modes. But to use them, you need to have a Cloudflare Origin Certificate installed on your website.

Using the full modes without the Cloudflare certificate installed is known to cause the 521 error.

To remove the 521 error from your website, you can either install the Cloudflare certificate or stop using the full mode and switch to the flexible option.

To switch to the Cloudflare flexible mode, you need to take the following steps:

  • Open your Cloudflare dashboard
  • Go to SSL/TLS
  • Select flexible

That’s it.

Switching to Cloudflare flexible mode.

4. Seek help from the hosting provider or Cloudflare support

None of the solutions worked? Then seeking help from your hosting provider or Cloudflare support team is the only option left. Be sure to tell them all the steps you have already taken to remove the error from your website. They should be able to help get your website up and running in no time.

Conclusion 🧐

The Cloudflare error 521 is a common Cloudflare error and it typically appears on a WordPress website when Cloudflare is unable to connect with the site’s hosting server.

This happens when the hosting server is offline or the server is actively blocking Cloudflare, mistaking it for a spam service.

👉 To remove the 521 error from your site, you need to take the following steps:

  • Clear your browser cache
  • Check if your hosting server is down
  • Whitelist Cloudflare IP ranges
  • Choose the proper Cloudflare encryption mode
  • Seek help from your hosting provider

If you have any questions about the Cloudflare error 521, leave us a comment below.

Free guide

4 Essential Steps to Speed Up
Your WordPress Website

Follow the simple steps in our 4-part mini series
and reduce your loading times by 50-80%. 🚀