Bobcares

Cloudflare Error 520 | Troubleshooting Methods

by | Nov 5, 2022

With these methods, diagnosing and fixing the ‘Error 520: web server returns an unknown error’ for Cloudflare proxied sites has become a simple task. Bobcares can address your server-related concerns with our Server Management Services.

Cloudflare ‘Error 520: Web Server Returns An Unknown Error’

If we own a website, we may have received multiple inquiries about “Error 520: Web Server Is Returning an Unknown Error.” This occurs when the origin server returns to Cloudflare an empty, unknown, or unexpected response.

 

cloudflare error 520

Factors Resulting Error 520

Over the time, we identifies different reasons as error causing factors. So to make troubleshooting more effective, we must first determine what is causing the mistake. Let’s look at the conditions in which we run into the error 520.

  • When the origin server does not accept connections from Cloudflare IP addresses.
  • When web server at the source crashes.
  • When TCP idle timeout value less than the default idle timeout value.
  • When HTTP header size exceeds Cloudflare’s request header size limit of 16 KB.

How To Troubleshoot Cloudflare Error 520?

To keep our customers, we must ensure that the site is operational at all times. Therefore, we must correct the error as soon as we notice it. This section describes some of the methods available to help you with this problem.

Check the DNS and make sure that the records are correct: An empty or unexpected response from the origin web server can result from incorrect DNS records. How can we check the DNS records? Let’s see the simple method by our Support team.

  1. Firstly locate domain’s IP address by accessing domain’s DNS zone editor.
  2. Now log in to the Cloudflare dashboard.
  3. Lastly, confirm the DNS records are correct.

Check the size of header and cookies and make sure they lie within the limit: Request headers from Cloudflare are limited in size overall to 32 KB and individually to 16 KB. The 520 error response appears if the headers go over the allowed number. To examine the headers and cookies of the website, we can use the server’s HAR (HTTP Archive). We can check the HTTP Archive by following the below methods:

  1. To access the developer tools, right-click the website where error 520 is visible and select Inspect.
  2. Then click on the Network tab.
  3. Click on the small round button if it’s gray.
  4. Also check the Preserve log box.
  5. Now refresh the page and reopen the network tab.
  6. Then right click anywhere on the developer tools window.
  7. Select Save all as HAR with Content.
  8. To examine the file, we can use any online HAR Analyzer.

Examine error logs: We can analyse the error logs exist to identify the error source. The error log location varies depending on the hosting platform. We can find a site’s PHP error log by following these steps.

  1. Locate the .htaccess file from the site’s root directory using the file manager or an FTP client.
  2. Then open the .htaccess file and insert the following code:
    php_flag log_errors on
    php_value error_reporting 32767
    php_value error_log "error_log.txt"
  3. Create a file titled error_log.txt in the public_html directory.
  4. Save and close it. When the site encounters any trouble, open the error_log.txt, and we can see the PHP error logs.

cURL command: cURL command used for sending HTTP/HTTPS requests can also be used to troubleshoot HTTP error responses. How to use cURL command to troubleshoot the error?

curl -vso /dev/null --user-agent "Mozilla 5.0" -H "Host: site.com" http://123.45.6.739/wp-login.php

Replace “site.com” with the actual domain and “123.45.6.739” with our site’s IP address. If everything’s okay and the site was reached without an error 520 response, the response header would look similar to the example below:

* Hostname was NOT found in DNS cache
*   Trying 123.45.6.789...
* Connected to 123.45.6.789 (123.45.6.789) port 80 (#0)
> GET /login HTTP/1.1
> User-Agent: Mozilla 5.0
> Accept: */*
> Host: your-site.com
>
< HTTP/1.1 200 OK
< Content-Type: text/html
< Date: Day, DD, Month Year Hour:Minute:Second Timezone
{ [12345 bytes data]
* Connection #0 to host 123.45.6.789 left intact

Else, the response header looks like this:

* Hostname was NOT found in DNS cache
*   Trying 123.45.6.789...
* Connected to 123.45.6.789 (123.45.6.789) port 80 (#0)
> GET /login HTTP/1.1
> User-Agent: Mozilla 5.0
> Accept: */*
> Host: your-site.com
>
* Empty reply from server
* Connection #0 to host 123.45.6.789 left intact

Disable Cloudflare: By disabling Cloudflare, we can troubleshoot the error 520.

  1. Firstly, login to the Cloudflare dashboard.
  2. Now click on the DNS tab.
  3. Then select a domain and toggle the Proxy status button.

At most times, we can troubleshoot the error with any of the above mentioned methods. We can help you further if you need any additional help.

[Need assistance with another query? We are just a click away.]

Conclusion

In conclusion, we have provided different methods to troubleshoot the Cloudflare error 520 provided by our Support team. This article also includes the possible reasons which leads to the error.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.