How to Fix Cloudflare’s “Error 520: Web Server Is Returning an Unknown Error”

1 vote, average: 5.00 out of 51 vote, average: 5.00 out of 51 vote, average: 5.00 out of 51 vote, average: 5.00 out of 51 vote, average: 5.00 out of 5 (1 votes, average: 5.00 out of 5, rated)
Loading...
Resolve Cloudflare Error 520

A visitor enthusiastically hops into your site, searching for some information. When they click on it, all they see is this message, “Error 520: Web Server Is Returning an Unknown Error”.

They try again and the same thing appears. Feeling disappointed, they left your site and visited your competitor’s site.

There, you lost a potential lead!

Not only this but you may also realize you aren’t able to log in to the site dashboard. Thus, resolving Error 520 is important for continuous access and provides the best user experience.

In this article, we’ll understand what Error 520 is, its possible causes, and how to fix Error 520.

Let’s dive right in!

What’s Cloudflare Error 520?

“Error 520: web server is returning an unknown error” implies that Cloudflare is unable to connect to your original web server. Instead, the server returns an unknown, unexpected, or empty response to Cloudflare.

Thus, if you encounter the above message when using Cloudflare, know that the connection is not established. This also means the server can’t process the user request, hinting at the website’s unavailability.

Causes of Error 520

You may receive Error 520 due to a number of reasons:

  1. TCP timeouts: It occurs when the server’s default idle timeout (300 s) exceeds the TCP idle timeout. Consequently, no connection is established between the server and the client.
  2. TLS/SSL handshake issues: If there’s any issue in the TLS/SSL certificate on the origin web server, it results in handshake failure. The issue could be the certificate’s expiry, invalidity, or misconfiguration.
  3. Server Crashes: A website’s PHP-based coding might freeze or crash, preventing the server from processing user requests.
  4. Denied IP addresses: Your firewall might block some IP addresses not in its allowlist, rejecting the connection.
  5. Header and Cookie Issues: Too many cookies or large headers (exceeding 16 kb) during the connection may result in server overloads, resulting in Error 520. Also, if the request has insufficient header information, the server can’t correctly process the request.
  6. Incorrect DNS Records or .htaccess file: If the DNR records corresponding to the server are incorrect, the browser can’t find the server, and you get Error 520. Similarly, if the site’s code has a flawed .htaccess file, the server can’t properly process the user request, resulting in Error 520.
  7. Empty Server Response: If the browser doesn’t receive any server response, it can’t show anything, causing Error 520.

How to Fix Cloudflare Error 520?

Follow the below steps to fix “Error 520: web server is returning an unknown error”:

Try Connecting Again

Sometimes, the error could be temporary. Issues like high traffic volumes or server overloading can cause the server or network to deny or delay requests.

When this happens, it will start fixing the issue or scale up resources automatically to accommodate the load. Thus, it will require some time to process the requests.

So, wait for a while and refresh the web page to check if the problem is resolved. If not, there are other methods you can try.

Pause Cloudflare

If you are using Cloudflare’s reverse proxy and getting Error 520, try disabling Cloudflare. Follow the below steps to do it:

  1. Log-in to Cloudflare.
  2. On your screen’s left-hand panel, find “Overview” and click on it.
  3. Scroll down to reach “Advanced Actions”.
  4. You will find the option “Pause Cloudflare on Site” to disable Cloudflare temporarily from your site.
  5. Hit “Confirm”.

Check Error Logs

Error logs provide crucial information, which will help you resolve the issue faster. It includes data, such as:

  • Incident and it’s root cause
  • Source
  • Date and time
  • Client IP address

However, the process of creating error logs can differ based on the hosting service. For cPanel users, here’s how you can check error logs:

  • Log in to your cPanel.
  • Inside your dashboard, locate “Metrics”.
  • Locate “Errors” and click on it. It will show you up to 300 recent error logs.

Inspect Cookies and Headers

If the overall request header’s size is larger than 32 kb, it will show Error 520. Also, too many cookies increases the header size. Thus, it’s essential to optimize cookies and headers, keeping it under 16 kb per header and 32 kb overall, so that user requests can be processed without hassles. Steps to do it are as follows:

  • Open the page showing Error 520.
  • Right-click on the web page and choose “Inspect”. It will open developer tools.
  • Inside the panel, look for “Network” and click on it.
  • Check the box for “Preserve log”.
  • Clear network activities by clicking on “Clear”.
  • Capture new network activities by reloading the page.
  • Right-click on the page anywhere and choose “Save all as HAR with content”.
  • Select a location to save this HAR file on the computer. Click on “Save”.

Correct DNS Records

Incorrect DNS records can cause Error 520, so check the records and correct them. Here’s how to do it:

  • Login to your DNS account. You can also do it through the hosting provider.
  • Find out whether the records are correct or not, like CNAME.
  • Update the records.

Disable .htaccess

.htaccess or hypertext access files are configuration files for Apache-based websites. Sometimes, if this file gets corrupted or has some other flaws in it, the web server can’t process user requests.

So, if your site is hosted on Apache Web server, disable the .htaccess file to resolve the issue. Also, ensure your firewall or .htaccess file don’t have settings to block Cloudflare IP addresses. To disable the file, follow the steps:

  • Open .htaccess file.
  • Change “AllowOverride” to None.
  • Save the file changes. Restart Apache.

Use cURL

cURL or client URL is a command that you can use to send HTTPS/ HTTP requests and fix HTTP errors. So, run the cURL in the command terminal by following these steps:

For Windows:

  • Pressing Windows + R keys from your keyboard
  • Typing “cmd

For macOS:

  • Go to “Applications“.
  • Click on “Utilities”.
  • Choose “Terminal”.

Thus will trigger a request to the web server and obtain a complete response.

cURL format: curl -I http://xyz.com

Running this command will help you understand an error response and a successful response. Thus, you can check whether the server is properly configured.

Restart PHP

Sometimes, Error 520 can occur due to PHP code crashing or malfunctioning. So, consider restarting PHP. It might differ with the type of server and software the server runs. To restart PHP:

  • Log-in to your server hosting account or web server
  • Find the site’s configuration file. It can be something like php.d, php.ini, conf.d, etc.
  • Review the file to check for flaws in terms of size, execution time, etc. Edit if something isn’t right.
  • Restart PHP by entering the server command.

Seek Support

If you have tried everything and still Error 520 keeps showing, reach out to Cloudflare’s support team.

Conclusion

Error-520 is a serious issue that you must resolve quickly if you want to have seamless access to your site dashboard and deliver the best user experience. So, if you face Error 520, resolve it quickly by following various ways as explained above.

Protect your Website’s Sensitive Data with Trusted SSL/TLS Certificates!

~ Starts at just $2.99/yr

Janki Mehta

Janki Mehta is a Cyber-Security Enthusiast who constantly updates herself with new advancements in the Web/Cyber Security niche. Along with theoretical knowledge, she also implements her practical expertise in day-to-day tasks and helps others to protect themselves from threats.

Buy Cheap Wildcard SSL