How To Resolve Cloudflare Error Code 520: A Complete Guide

  • Share on

  • Share on

  • Share on

Most people in today’s fast-forward era are quite familiar with Cloudflare for being the topmost Internet security provider. As per the latest stats, the platform has successfully surpassed 4.1 million global users. This Internet security company provides its outstanding services to more than 7.59 million websites all over the web.

With its growing success, Cloudflare has been catering to its customers in plenty of ways. However, a common problem faced by the Security Service is the error code 520. Any website using Cloudflare can indicate this error with the message error 520: Web server is returning an unknown error.

As an owner, every professional needs to be able to resolve any issues going on with their websites. Hence, we have shared a comprehensive guide for website owners to help them resolve the error code 520.
But before we proceed, let us know what is the error code 520 and why does it occur.

Introduction To Cloudflare Error Code 520

What Is Error Code 520?

The Cloudflare error 520 is an extreme network issue that indicates that the web page requested by the user cannot be reached. It is to notify that the web server has received an incorrect request or it may have interpreted a user request incorrectly. Due to this, it results in an empty response denoting that the server is returning an unknown error.

Why Does the Error Code 520 Occur?

Most experts share a few common reasons why error 520 occurs. some of these are listed below.

  • Incompatibility With Cloudflare’s Response Headers

Cloudflare has a limited header size of 16 KB. HTTP headers indicate the web server's primary details such as the browser being used, the page being requested, and the required cookies. These headers have the responsibility to connect the web browser with the client.

However, and there are plenty of requests on the server, the number of cookies may exceed the header size of Cloudflare. For this reason, the platform resource with invalid response or shares the message of missing headers.

  • Default Firewall Settings

Most firewall settings block and blacklist unknown apps. Your firewall may have blacklisted Cloudflare's IP address too. For this reason, an error occurs denoting that the origin servers do not allow connections.

  • Short-Duration TCP Idle Timeout

TCP or transmission control protocol establishes a reliable and secure connection between the client and the web server. If the value of TCP timeout is below 300 seconds, a Cloudflare 520 error occurs. Because the default value of TCP idle timeout is 300 seconds, the platform denotes this error.

  • The Origin Web Server Crashed

When the origin web server is unable to interpret user requests properly or in case it is running a script that is user-intensive, the 520 error code can occur at Cloudflare.

How To Resolve theCloudflare 520 Error?

Now, let us look forward to a few expert-recommended ways that may help troubleshoot the error 520 at Cloudflare.

Disable Hypertext Access File

The hypertext access file or .htaccess file plays a major role in the global configuration of every Apache server while making sure the overall configuration of these files is unaffected. In case the .htaccess file is corrupted or some of its configuration is improper, Cloudflare declares the 520 error. Hence, you can quickly disable this .htaccess file to find out whether there is a problem with the file or not.
Below, we have discussed the steps to disable the .htaccess file.

At first, open the Apache2.conf file through a text editor. By default, you can find the file in one of the following locations.

  • /etc/httpd/httpd.conf
  • /etc/apache2/httpd.conf
  • /etc/apache2/apache2.conf
  • /etc/httpd/conf/httpd.conf
  1. Search for the value of the AllowOverride directive.
  2. Change the value of the AllowOverride directive to None.
  3. Save the changes and close the file.
  4. To apply these changes, restart Apache.

Check Cookies and Headers

the size limit of an individual header for Cloudflare is 16 KB. It makes the overall limit of header sizes to 32 KB. In case, the header exceeds this default limit, the error 520 occurs. To check and review the header of a website, open the HTTP Archive or HAR file.

This HAR file is responsible for holding the web browser details while recording all the browser requests. It also includes the details of the request header, page load duration, response header, and body content. Experts recommend generating HAR files as they help to analyze deeply the error cause and find a suitable solution.

Unfortunately, many people do not know how to generate HAR files. Hence, we have shared the steps to help you understand.

How To Generate HAR Files Easily?

Primarily, HAR files can be used for troubleshooting errors as they carry a detailed comparison between the response headers of Cloudflare and the original server. Also, these files can be used to calculate the standard size of these headers.

To easily generate HAR files on different browser types, follow the steps below.

  • HAR file using Firefox

  1. Open the Firefox web browser and right-click on the page.
  2. From the drop-down menu, select Inspect Element.
  3. Check the Network tab and go to the page that is encountering the Cloudflare error 520.
  4. Find the Messages option in the panel and right-click on it.
  5. From the drop-down menu, select the option Save All as HAR.
  6. Choose the location on My Computer and save the file.
  • HAR file using Chrome

  1. Open the Google Chrome web browser and right-click on the page.
  2. From the drop-down menu, select Inspect.
  3. Wait for the panel to open.
  4. From the panel, open the network tab.
  5. On the top left-hand side of the window, look for a record button.
  6. If the record button is grey, click on it.
  7. Click on the preserve log option to check it.
  8. Now, click on the clear button beside the record button.
  9. Load the web page with the Cloudflare error 520.
  10. Now, on the Chrome developer tool, right-click on the messages area.
  11. From the drop-down menu, select the option Save as HAR with Content.
  12. Choose the location on My Computer and save the file.
  • HAR file using Safari

  1. Open the Safari web browser.
  2. If you are a Windows user, right-click on the page.

If you are a Mac user, press CMD on your keyboard.

  1. Now, from the drop-down menu, select the option Inspect Element.
  2. Wait for the panel to open.
  3. From the panel, open the network tab.
  4. Click on the preserve log option to check it.
  5. Load the web page with the Cloudflare error 520.
  6. Now, click on the Export option to generate an HAR file.
  7. Choose the location on My Computer and save the file.
  • HAR file using Edge

  1. Open the Microsoft Edge web browser and right-click on the page.
  2. From the drop-down menu, select Inspect.
  3. Wait for the panel to open.
  4. From the panel, open the network tab.
  5. On the top left-hand side of the window, look for a record button.
  6. If the record button is grey, click on it.
  7. Click on the preserve log option to check it.
  8. Now, click on the clear button beside the record button.
  9. Load the web page with the Cloudflare error 520.
  10. Now, on the developer tool, right-click on the messages area.
  11. From the drop-down menu, select the option Save as HAR with Content.
  12. Choose the location on My Computer and save the file.

Investigate Error Logs

Most error messages include information about the error that may help to resolve it. Also, error logs consist of additional information about the error including its location, cause, and the type of error that occurred.

Unfortunately, to generate or locate error logs, you must check your hosting provider as the process depends on it completely. However, to help you understand, most error logs will provide you with the following details.

  • The error messages
  • The time and date of the error encountered
  • The IP address of the client or user.
  • A path to the resource that is causing the error.
  • A line of code due to which the error is being encountered.

Try a cURL Command

The Client URL command or cURL command is used to send HTTP or HTTPS requests. However, these can also be used to find information about the HTTP error code and relatable response headers.

The general syntax to generate the cURL command is,

sudo curl -svo /dev/null https://www.abc.com

If there is no error, a successful response will occur. below are the details that will showcase an error free response.

* Trying 111.11.1.111...
* Connected to 111.11.1.111 (111.11.1.111) port 100 (#0)
> GET /login HTTP/1.1
> User-Agent: YourBrowser 1.0
> Accept: */*
> Host: examplewebsite.com

< HTTP/1.1 200 OK
< Content-Type: text/html
< Date: Day, DD, Month Year Hour:Minute:Second Timezone
{ [11111 bytes data]
* Connection #0 to host 111.11.1.111 left intact

If the Cloudflare 520 error has been encountered, that responsibility will be abrupt with an unsuccessful attempt. It will showcase the following response.

* Trying 111.11.1.111...
* Connected to 111.11.1.111 (111.11.1.111) port 100 (#0)
> GET /login HTTP/1.1
> User-Agent: YourBrowser 1.0
> Accept: */*
> Host: examplewebsite.com

* Empty reply from server
* Connection #0 to host 111.11.1.111 left intact

Pause Cloudflare

If error 520 is being occurred due to Cloudflare, you can pause it to continue processing. 

Below are a few steps that you can take to pass Cloudflare easily.

  1. Log into your Cloudflare account.
  2. Visit the dashboard overview tab.
  3. Scroll down and find the option Advanced Actions.
  4. Click the pause Cloudflare on-site option.
  5. Confirm the request.

Remember that, when you pause Cloudflare, it will automatically turn off the security and protection features. Hence, it is better to use Cloudflare in the Development Mode.

Check Cloudflare DNS Records

Domain Name System or DNS records are particular files in the DNS authoritative servers. These specify,

  • The details of the IP address that is associated with the domain
  • The different steps to handle all user requests incoming to the domain

To let Cloudflare process smoothly, make sure that the Cloudflare DNS records are similar to those recorded in the domain's DNS Management System. To check the DNS records of Cloudflare for any website, pay attention to the following steps.

  1. Log into Cloudflare.
  2. Select the website that is showing the error 520.
  3. From the left-hand menu, click on DNS.
  4. Now, select Records.

Contact Cloudflare Support

In case none of the methods work for you, quickly connect with Cloudflare support service. 

Interestingly, Cloudflare offers two different options to contact with their support.

  • Live Chat – this option is available for enterprise and business accounts only.
  • Support Tickets – this option is accessible for all account types and is easy to access through the admin dashboard.

The Takeaway

The Cloudflare error 520 is confusing for many. However, it is a common error faced by most users. Hence, experts have tested and approved of the above-discussed methods to troubleshoot this error.
If you are a frequent Cloudflare user, you may have experienced this error too. Try each of these methods to ensure a smooth and proper processing of Cloudflare. Share your reviews about each of these methods in the comments below. Also, let us know about your experience with Cloudflare.

Previous Next
Robert Kevin

Robert Kevin

Robert Kevin is a versatile content writer known for captivating storytelling and impactful writing. His well-researched articles and compelling blog posts leave a lasting impression on readers.