Error 521

Error 521 is essentially a Cloudflare-based message that usually occurs when the WordPress website server is unable to establish a connection with Cloudflare.

”Error 521 Web Server is Down” appears for various reasons and very often, it is one of the most difficult errors to resolve

Unlike other codes that are related to quite unique situations, error 521 is indeed related to websites that use CloudFlare. But, at the same time, it doesn’t say much about specific causes and situations. This actually complicates its resolution.

In order to help you get an overview of error 521 and understand how you can solve it, I suggest you read this article carefully

Chapter 1: What causes Error 521 and how to recognize it?

In order to provide you with a perfect understanding of the concept of Error 521, here are the points that we will develop together in this first chapter:

  • Definition of Error 521;
  • Definition of Cloudflare ;
  • Causes of Error 521 and clues to recognize it.

1.1) What is the 521 error?

Error 521, also known as server not found, is an error particularly related to websites hosted with Cloudflare. It often tends to work like the 504 gateway error, but the difference lies in the problem that caused the error.

As a reminder, it means that Cloudflare’s connection to the origin server on port 80 or 443 was rejected, resulting in users seeing the 521 code.

Source hooshmand

As a result, the user will receive a connection rejection message that may or may not make it clear that it is a 521 code.

1.2 What is Cloudflare?

It is a network that has the role of content delivery and works as a proxy between the visitor’s browser and your website.

Cloudflare is mainly used to improve the performance, speed and security of applications and websites

In addition, Cloudflare secures the website against identity theft or SQL injections as threats.

1.3. Main causes of Cloudflare error 521

There are three main problematic factors that can cause this error in the user’s system while using Cloudflare service. And these factors are explained as follows:

  • Web server is offline

The first problem that can cause this error in a Cloudflare user system is an idle origin web server

Sometimes, the original web server process like Apache or Nginx is unable to run or crashes due to a server malfunction. And across the board, these things create the 521 error.

  • Blocked Cloudflare requests

The second main thing that can create this error in Cloudflare is the request block issue

In some situations, the origin web server or the hosting provider’s network blocks Cloudflare requests and, as a result, creates connection blocking scenarios

And the 521 error is essentially a way in which Cloudflare informs its users of this problem.

  • Poor detection

Due to its proxy nature, Cloudflare accesses your WordPress server with an IP address that is often the same. In fact, the IP address of each visitor should be different.

This is why your server security system may consider it a hacker attack

This is because the server detects the amount of traffic from IP addresses that are similar to each other. As a result, the server will block the Cloudflare IP address and an error code 521 will appear.

1.4. How to recognize the 521 error?

It is not always obvious that this error only occurs during a browsing session or that you receive a message indicating that you are facing a 521 error. It can occur in several ways, including the following:

  • It can occur by closing the window of the active programs on your computer;
  • It may involve frequent blocking of your computer when running the same program or website;
  • There is a 521 error when you receive a ”Can’t open Clipboard” message;
  • The expression ”Clipboard has already been opened by another application” can also mean a 521 error.

These 521 error messages are likely symptoms that will let you know the nature of the error if you don’t have a concrete indication.

Chapter 2: How to fix error 521 for WordPress and Cloudfare?

Since the 521 code is mostly related to WordPress sites, in this chapter we will find out some ways to fix Cloudflare error 521 in WordPress.

Here are the tips I’ll suggest:

2.1. Check if the original server of your site is online

So, before further analysis, you should first make sure that the original server on which you are hosting the website is online.

For testing purposes, I recommend using the cURL command on the original IP server. Especially for those of you using Mac or Linux, you can test directly from the terminal

For example curl 103.56.149.29.

If there is a response, it means that there is no problem with the original server you are using.

Using the cURL command is not a possibility when you are in Windows. The possible checking option is the use of tools such as HTTP Header Check

Simply enter http //1.2.3.4where 1.2.3.4 is considered the real IP address of your server.

Source kinsta

You can find your server’s real IP address from the A record setting that points to your domain in the Cloudflare dashboard.

If your server is UP or Online, an HTTP 200 response usually appears, or if you are using a VPS, the response may be 404 Not Found or 403 Forbidden depending on your VPS settings.

Source fixrunner

But basically, this shows that the origin server is online, as it always gives a response.

Now, what you need to pay attention to, if the origin server is down, the information is Host Not Found or Failed to connect.

In case you suspect that your server is complicit in the problem, then you need to contact your hosting company.

2.2. Grant access to Cloudflare IP addresses

If the server is online and the 521 error keeps appearing, it means that you need to grant access or whitelist all Cloudflare IP addresses so that they are not blocked by the server.

To do this, you need to modify the .htaccess. However, all Cloudflare IP addresses must be confirmed as not blocked.

If you are confused or have any doubts about editing the .htaccess file, just contact your hosting company. You can ask for their help to modify it.

2.3. Check and fix the error in the .htaccess file

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

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

The corrupted .htaccess file is not the reason for error 521. So the solution is also different. To fix it, the first step will be to open the .htaccess file:

  • You can open the file manager from cPanel.
  • Inside, you will see the .htaccess file. Otherwise, you can access the settings from the top menu. Click on the settings, 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 will see the file editor.

Source Fixrunner

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

If the .htaccess file blocks any of the IP addresses, you will need to remove the block. Once this is done, you can try reloading the website to see if it works or not. This will surely solve the problem.

2.4. Change HTTP to HTTPS

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

Now, when you enable SSL, Cloudflare redirects websites to HTTPS. However, if your actual WordPress domain is set to HTTP, the contradiction will arise. Cloudflare will try to redirect the URL to HTTPS while the website will try to redirect the URL to HTTP. As a result, you will see the error.

The easiest way to solve this problem is to change HTTP to HTTPS. To change it, you can go to the WordPress settings

In the general settings, you will see the option to change the URL. Change the URL and reload the page

Now you can try reloading the website again to see if it works. If everything went well, the website will work fine.

If not, make sure you don’t have the redirect plugin that is causing the problem. If you have a redirect plugin installed, it can cause problems. It is recommended to disable it to see if the plugin is the problem or not. If the plugin is the problem, everything will be better after disabling it.

2.5. Change full SSL to flexible SSL

Cloudflare has different options you can use when it comes to the SSL certificate. The two options we will be concerned with are

  • Full SSL ;
  • Flexible SSL.

Along with these, there are also various other options. However, we will only consider these two to stay in line with our topic

Very often, full SSL is sometimes complicit in this error. So, you can simply convert the SSL certificate to flexible instead of full.

Here are some steps to access this option

  • First, you will need to log in to the dashboard;
  • Then you can select the crypto option from the menu tabs
  • Take a look at the sidebar and you will see the option to select SSL;
  • Change the SSL certificate from full to flexible;
  • Wait for it to be activated;
  • Try loading the website again to see if it worked or not.
Changez SSL complet en SSL flexible

Source Fixrunner

Here is a video that shows you step by step how you can do it:

Alternatively, if you have the Cloudflare WordPress plugin installed on your website, you can also change things from there

If you don’t have it installed yet, you can install Cloudflare Flexible SSL from the WordPress plugin directory

2.6. Contact support

If nothing works, you can probably contact support and see what they have to say about it. You still have two options here. You might not know whether you should contact hosting support or you should contact CDN support.

You can contact hosting support first and ask if there is anything wrong with the server. If you are still not satisfied, then you can contact Cloudflare support team.

In most cases, the problem is related to the hosting and not to Cloudflare. Therefore, you need to contact the hosting support first and then if you don’t have a solution, you can contact Cloudflare support to see what is wrong.

You need to perform the above tips first and if nothing works, you can contact the support.

But in the chapter below, we will see some web server repair solutions.

Chapter 3: Troubleshooting broken server problems

Troubleshooting server problems is never an easy task. Whether you have a small home server or a giant with thousands of computers, you need to follow meticulous steps to get it back up and running

Here is a complete overview of the steps you need to follow when troubleshooting.

3.1. Analyze your network infrastructure

You’ll have a better chance of solving network problems if you start by figuring out where everything is connected in the infrastructure.

Reseau Datacenter Communication

Source Ezynow

You’ll be able to spot network vulnerabilities by discovering all the applications, processes and computers on the network.

3.2. Study your network

Several tools can help you map the entire network infrastructure. Tools such as IPCONFIG can help find the problem

3.3. The connection is broken

From the network troubleshooting application, find out from the OSI model if all seven layers are working properly. Usually, if the first layer is not working, the whole connection will be broken

Les 7 couches du modele OSI

Source Sites.google

Check if the network cable is connected. The problem may also be a broken connection when the network cable is disconnected or cut. Also check if the network switch is working properly.

3.4. No IP address

Your server may be down simply because of unknown IP address settings. A null IP address such as 0.0.0.0 or an automatic address starting with 169.254 will usually cause server failure problems

You will need to obtain a valid IP address before you can back up your server

Adresse IPv4

Source Wikipedia

To solve this problem, open the Networking and Sharing Center and select ”Get IP address automatically”

You can also activate a dHCP server (Dynamic Host Configuration Protocol) server to solve the problem.

3.5. No DNS servers

Without configured DNS servers on your network, all communication will only be possible via an IP address. A problem with a downed server in this case can be a line break between the router and the Internet

Qu est ce que le DNS

Source Slideshare

To solve this problem, set the DNS server to a manual configuration and fill in the server IP addresses. You can also configure Google’s public DNS servers to help you ping and track blocked packets.

3.6. No default gateway

Your servers might be down because there is no default gateway IP address. This interrupts communication between the subnet and the local network

Passerelle Serveur Internet

Source Infoforal

You will still be able to work as usual on your local servers. However, if you need to access an external network, you will have to configure a gateway IP address manually.

3.7. Misconfigured IP Subnet Mask

A misconfigured subnet mask IP address can hinder communication with the server

Adresse IP Masque Sous reseau Hote

Source Sti2d

You can configure this IP subnet mask manually or work with the DHCP server to identify the source if it is misconfigured.

Chapter 4: Other Questions Asked about Error 521

4.1. What is Error 521?

Error 521 “Web Server is Down” is an error directly related to the Cloudflare 521 error message (similar to error 520) that appears whenever your web server cannot connect with Cloudflare

4.2. What is Cloudflare?

Cloudflare is generally used to increase the security and performance of web applications. It improves the overall performance, security, and reduces the load time of any website hosted through Cloudflare.

4.3. Why does error 521 occur?

The 521 Web Server is Down error can be caused for several reasons, specifically in these three cases:

First, the 521 error occurs because the original web server is refusing a connection from Cloudflare. Specifically, Cloudflare tried to connect to your origin server on port 80 or 443 but received a connection error.

Second, your WordPress site’s server may be down (temporarily). Even if everything is configured correctly on your end, the server may be offline. In this case, Cloudflare will not be able to connect and will display Cloudflare error 521.

Third, your website’s server may be working properly, but may be blocking Cloudflare’s connection requests for some reason

4.4 How do I fix the Cloudflare error?

  • First of all, make sure that your original web server is responsive;
  • Review the error logs of the origin web server to identify web server application failures;
  • Ensure that no Cloudflare IP addresses are blocked or rate-limited;
  • Provide access to all Cloudflare IP address ranges in your origin web server’s firewall.

4.5. What does downed web server mean?

A server can go down for many reasons. Perhaps a physical machine is losing power, or perhaps the operating system or network card is having a problem

4.6. How do I fix the crashed server?

Here are some practical actions that can help you:

  • Analyze your network infrastructure
  • Study your network;
  • Make sure the connection is not broken;
  • Make sure your IP address is not invalid;
  • Make sure there is a DNS server;
  • Make sure there is a default gateway;
  • Make sure that the IP subnet mask is properly configured.

Conclusion

Error 521 is a code specifically related to websites, whose resolution is a bit more complex unlike the other codes.

But in this article, we have taken the time to develop the basic concepts that can be difficult to understand. By following my advice, you will easily avoid or correct the 521 code

If you have any other questions, feel free to put them in the comments below.

Thanks for reading and see you soon!

Categories E

Leave a comment