8 Fixes for Cloudflare Error Code 520

error code 520

Cloudflare’s error code 520 means the Cloudflare system can’t reach the website. It is a common issue that happens for several reasons. Troubleshooting these reasons can get complicated as the investigation can include areas such as DNS records and server configuration. 

The challenge in resolving error code 520 is to pinpoint the exact reason. The situation can get complicated because the error could happen for many reasons. You need to understand what might be causing the problem to fix it.

In this detailed guide, we will discuss Cloudflare error code 520. In addition, we will describe 8 fixes for resolving this error.

Let’s start with an overview of the error.

Table Of Contents

  1. What Is Cloudflare Error Code 520?
  2. What Causes Error 520?
  3. 8 Fixes for Troubleshooting and Fixing Error Code 520
    1. Fix #1: Pause Cloudflare
    2. Fix #2: Check the DNS Records
    3. Fix #3: Restart PHP on the Server
    4. Fix #4: Check Headers and Cookies
    5. Fix #5: Disable the .htaccess File
    6. Fix #6: Check Web Server Error Logs
    7. Fix #7: Verify HTTP Error Response using a cURL Command
    8. Fix #8: Contact Cloudflare Support
  4. Conclusion
  5. FAQs

What Is Cloudflare Error Code 520?

Error 520 from Cloudflare means that Cloudflare’s network received an empty or incomprehensible response from your server. Since Cloudflare cannot understand the response, the users see the error code 520 in their browsers.

What Causes Error 520?

The main reasons for error 520 are:

  • PHP apps on your server have stopped or are not working properly.
  • The server’s DNS records are set up incorrectly.
  • The .htaccess is corrupted or incorrectly set up.
  • The incoming requests have too much information, or the server uses too many cookies.
  • The requests don’t have the needed request headers.
  • The server is not sending any reply or information back to Cloudflare’s network.

8 Fixes for Troubleshooting and Fixing Error Code 520

Now that you know what causes the error, you can explore the following solutions that target various underlying issues that cause this error. 

Important: Before trying these solutions, ensure the website having issues is unreachable and that Cloudflare’s system status page shows All Systems Operational.

Fix #1: Pause Cloudflare

If you suspect the problem lies with Cloudflare, you can temporarily stop it to allow the page with the error to be reachable again.

You can follow these steps to pause Cloudflare for your website: 

  • Sign in to your Cloudflare account.
  • Go to the Overview section on the left side of the screen.
  • Scroll down to the Advanced Actions area and choose Pause Cloudflare on the site.

advanced actions

Fix #2: Check the DNS Records

DNS records are documents stored in designated DNS servers. These records include critical information, such as:

  • The IP address is linked to your domain.
  • The data required for managing requests that come in for that domain.

In some cases, the error code 520 happens when the Cloudflare’s DNS records do not match those in the domain’s DNS management system.

If you think this is the root cause of the problem, start by finding the DNS records for the website in Cloudflare by following these steps:

  • Sign in to your Cloudflare account.
  • Choose the website where the error 520 is happening.
  • On the left side, click on DNS and then choose Records.

Check the DNS Records

Next, we recommend matching the information with the domain’s DNS information. The exact steps of the process depend on your domain registrar.

Fix #3: Restart PHP on the Server

Error 520 might occur when a PHP application stops working on your server. Restarting the PHP service on the web server could resolve the situation in such cases. In most cases, we recommend restarting the server to reload all services. Many hosting platforms let users restart PHP through the visual settings manager (GUI).

We will now briefly discuss how to restart the Apache web server and NGINX server deployed in a Linux environment. 

Restart the Apache Web Server

To restart an Apache server on Ubuntu or Debian, use the following command:

# sudo systemctl restart apache2

To restart an Apache server on a CentOS 7 machine, run the following command: 

# sudo apachectl -k restart

Restart the NGINX Web Server

To restart an NGINX server, use the following command:

# sudo systemctl reload nginx

To forcefully restart an NGINX server, run the following command:

# sudo systemctl restart nginx

Alternatively, you can forcefully shut down and restart an NGINX server with the following command:

# sudo /etc/init.d/nginx restart

Many hosting platforms let users restart PHP through the visual settings manager (GUI).

Fix #4: Check Headers and Cookies

Cloudflare limits the size of the request headers to 32 KB, with each header limited to 16 KB. When the headers exceed these limits, the system can throw up error code 520.

We recommend looking into the origin server’s HTTP Archive (HAR) file to check details about the size of request headers. Follow these steps in Google Chrome to check this information:

  • Go to the webpage that’s showing the 520 error.
  • Click the right mouse button and choose Inspect.

error 520

  • Choose the Network tab.
  • Enable the Preserve log option.
  • Press the Clear button (it looks like a stop sign).

inspect dashboard

  • Refresh the page.
  • Click the right mouse button just below the navigation bars.
  • Choose Save all as HAR with content.

save HAR

The process of creating a HAR file is nearly the same in most major web browsers because they’re all based on the Chromium engine. Note that this is not true for Firefox because of its different engine.

You can only analyze HAR files with tools like Google’s HAR Analyzer.

Important: HAR files have sensitive information like cookies and passwords. Before sharing them, sanitize the content by deleting any personal or compromising data.

While analyzing the HAR files, check for unusually big cookies and an overall excess of cookie usage.

You can try the following ideas to make cookies smaller and lessen the load on request headers:

  • Get rid of any extra third-party plugins on the website.
  • Reduce the amount of request overhead.
  • Utilize a domain without cookies.

Fix #5: Disable the .htaccess File

The .htaccess file affects the overall setup of an Apache server without altering the main configuration files. An important use of this file is to set up redirects.

Error code 520 might show up if a redirect isn’t set up correctly in the .htaccess file or if the file is damaged. You can check if this file is causing the issue by turning it off temporarily.

To turn off the .htaccess file, first open the apache2.conf file in a text editor. We opened the file in Nano with the following command: 

# sudo nano /etc/apache2/apache2.conf

Note that we recommend checking the following locations to find the Apache config file:

  • /etc/httpd/conf/httpd.conf
  • /etc/apache2/apache2.conf
  • /etc/apache2/httpd.conf
  • /etc/httpd/httpd.conf

Locate the AllowOverride directive and change the value to None.

<Directory /var/www/html>

        Options Indexes FollowSymLinks MultiViews

        AllowOverride None

        Require all granted


After making changes, save and exit the file.

Now, you need to restart the Apache server to make the changes take effect. For this, run the following command:

# sudo systemctl apache2 restart

Fix #6: Check Web Server Error Logs

Server error logs give crucial details about where, why, and what went wrong and caused a specific error.

The steps in creating error logs depend on your hosting provider. However, all error logs have a similar setup and offer the following details:

  • When the issue happened, including the date and time.
  • The client’s IP address (if they’re the reason for the error).
  • A message describing the error.
  • The location of the resource having trouble or the specific line of code causing the problem.

Fix #7: Verify HTTP Error Response using a cURL Command

Client URL (cURL) is a great option for retrieving HTTP error response codes and request headers in a Linux environment.

The basic syntax of the command is:

# sudo curl -svo /dev/null https://yourwebsitehere.com

A positive response will appear like this:

*   Trying

* Connected to ( 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 left intact

Unfortunately, the command won’t fetch information when the 520 error happens, and the outcome will be like this example:

*   Trying

* Connected to ( 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 left intact

Fix #8: Contact Cloudflare Support

If you can’t fix error code 520 with the earlier steps, the next move is to reach out to Cloudflare support.

Cloudflare provides two ways to get support:

  • Support tickets are open to all accounts and can be accessed through the admin dashboard.
  • Live chat is only available for Business and Enterprise accounts.

In both instances, the representatives will ask for the following details:

  • The web address(es) of the troubled content.
  • The Ray ID from Cloudflare for the affected content.
  • Check what shows up when you enter the following URL in a browser: http://example.com/cdn-cgi/trace (make sure to use the correct domain, not “example.com”).
  • A HAR file from when Cloudflare was turned on for the website.
  • A HAR file from when Cloudflare was turned off for the website.

We also have a detailed tutorial on fixing Cloudflare error 521. 


Understanding and resolving error code 520 is crucial for maintaining a smooth online experience. Whether it’s due to issues with server configurations, DNS settings, or other technical aspects, the key is to follow systematic diagnostic steps. If you encounter challenges along the way or need expert assistance, consider reaching out to Cloudflare support. 

RedSwitches stands out as a provider to consider for reliable and dedicated hosting solutions. With their commitment to seamless performance, they can be your go-to partner in ensuring a robust and reliable online presence. If you’re looking for a robust server for your Linux projects, we offer the best dedicated server pricing and deliver instant dedicated servers, usually on the same day the order gets approved. Whether you need a dedicated server, a traffic-friendly 10Gbps dedicated server, or a powerful bare metal server, we are your trusted hosting partner.


Q. What is Error 520?

Error 520 is a response from Cloudflare indicating that a web server cannot fulfill a request. It occurs when the server receives an invalid or incorrectly interpreted request, resulting in an empty response.

Q. What causes Error 520?

Error 520 can be caused by various factors, including issues with PHP applications, misconfigured DNS records, a corrupt .htaccess file, large request headers, excessive cookie usage, or problems with the server itself.

Q. How can I troubleshoot Error 520?

Troubleshooting involves identifying the specific cause. Start by checking server logs, reviewing DNS configurations, examining request headers, and analyzing the .htaccess file. Cloudflare’s support and dedicated hosting providers like Redswitches can also assist in troubleshooting.

Q. How do I temporarily disable Cloudflare to check for issues?

Log in to your Cloudflare account, go to the Overview tab, scroll down to Advanced Actions, and select “Pause Cloudflare on Site.”

Q. What if the issue is with PHP applications?

Restart the web server hosting the website to resolve issues with PHP applications.

Q. How can I check request headers and cookie usage?

Generate a HAR file using browser developer tools to inspect request headers and analyze cookie usage.

Q. Why is the .htaccess file important?

The .htaccess file globally configures an Apache server. Issues in the file, like incorrect redirects or corruption, can lead to Error 520.

Q. How do I temporarily disable the .htaccess file?

Open the apache2.conf file, find the AllowOverride directive and change it to None. Save the file and restart Apache.

Q. What information do I need for Cloudflare support?

When contacting Cloudflare support, provide the URLs of affected resources, Cloudflare’s Ray ID, and results from entering http://example.com/cdn-cgi/trace in a browser. Share both enabled and disabled Cloudflare HAR files.

Q. Why choose Redswitches for dedicated hosting?

Redswitches offers reliable and efficient dedicated hosting services. With a commitment to seamless performance, they provide robust solutions to ensure a reliable online presence. Consider Redswitches for dedicated hosting needs.