Guide To Resolve Cloudflare Error 521

Cloudflare is the name of a popular content delivery network service which primarily offers effective reverse proxy options to its users. It works quite smoothly but, in some situations, users may encounter some minor hiccups while using it and error 521 is one of them. Most of the time, users get this error code when the origin web server refuses a connection request from Cloudflare. Now, if you are one of those users who is facing this error while using a Cloudflare service, then follow this article to know its possible solutions.

Main Causes of Cloudflare Error 521

There are two main problematic factors which may cause this error in the user’s system while using the Cloudflare service. And, those factors are explained in the area below. Have a look at them:

The Web Server is Offline

The first issue that can cause this error in a Cloudflare user system is an inactive origin web server. Sometimes, the origin web server process like the Apache or Nginx is unable to run or get crashed due to some server malfunction. And down the line, those thing creates the error 521.

Cloudflare Requests are Blocked

Now, the second main thing that can create this error in the Cloudflare is the request block issue. In certain situations, the origin web server or hosting provider’s network blocks the Cloudflare’s requests and hence, creates a connection blockade scenarios. And, the error 521 is basically a way through which Cloudflare inform its users about this issue.

Check the Root of Cloudflare Error 521 Occurrence

Before applying any solution, you need to find which issue is causing this error while using the Cloudflare and run some tests. Those tests will determine the responses of the origin servers and its problems. Now, to know about those tests and their execution steps, follow the given instructions.  

Test the cURL

If you are a Mac OS users, then you can run the cURL via Terminal command line tool to check the status of the origin server. To do this, follow the given steps:

  1. First, click on the Finder icon to open its window. Then, click on the Go option from the top menu bar.
  2. A scroll-down menu will appear on the screen. There you need to click on the Utilities option.
  3. Now, in the Utilities window, you need to locate and double-click on the Terminal. This will open the Terminal window, on the screen.
  4. In the Terminal window, you need to run a cURL command with your server IP using the A record or CNAME for your domain displayed in the DNS app of the Cloudflare dashboard. Example of the common line is “curl -v”.

If the origin servers start working, then you will get an HTTP 200 response along with the HTML of your website. However, if they are not, then you will receive a failed cURL request which will look like this:

“# curl

curl: (7) Failed to connect to port 80: Connection refused”

Run the Telnet

Now, those users who are using a Windows-based system, need to run Telnet via the Command Prompt instead of cURL in order to verify the status of the origin servers. To know about it, follow the given steps.

  1. Press the Windows key + X key to open up the WinX menu. Then, click on the  Command Prompt( Admin) option. This will open up Command Prompt window on the screen
  2. In that window, you need to run a command similar to this one: telnet 80.

After that, if you get an error message like the one mentioned below, then it means that your web server isn’t running or is blocking requests: Unable to connect to remote host: Connection refused.

But, if the error 512 is occurring due to a connection refusal issue, then you will get the following error messages:
“# telnet 80


telnet: connect to address Connection refused

telnet: Unable to connect to remote host”

Feasible Solutions to Eliminate Cloudflare Error 521

In order to resolve this error code from the Cloudflare, you need to follow some simple solutions and those are provided in the area below. Have a look at them and try to execute them as instructed.

  • Check the Web Server

If the error 521 is appearing on the system due to the Web server offline issue, then the first thing you should check is the server’s error logs. There you will find a list of all the problems which are causing this error. And with the help of that list, you will be able to verify and fix those causes quite effectively.

  • Whitelist all the Cloudflare IP

However, if your Cloudflare service is facing the request block issue, then in order to resolve that problem you need to whitelist all Cloudflare IP present in your server’s firewall or any other security applications. This will remove your Cloudflare IP from the block or rate-limited list and reactive the connection.


Now, if you are unable to solve this error by using the above-mentioned solutions, then you should contact your host provider in order to find effective solutions. We hope our solutions and suggestions are helpful to you regarding Cloudflare error 521. For more tech-related solutions, keep following our upcoming articles.

Maria Colombo
Maria Colombo
Articles: 1190