{"id":2941,"date":"2019-10-23T17:27:42","date_gmt":"2019-10-23T09:27:42","guid":{"rendered":"https:\/\/www.mondoze.com\/guide\/?post_type=kb&p=2941"},"modified":"2022-10-05T08:00:30","modified_gmt":"2022-10-05T00:00:30","slug":"error-520-web-server-is-returning-an-unknown-error","status":"publish","type":"kb","link":"https:\/\/www.mondoze.com\/guide\/kb\/error-520-web-server-is-returning-an-unknown-error","title":{"rendered":"Error 520: Web server is returning an unknown error"},"content":{"rendered":"\t\t
Error 520 is essentially a catch-all response when something unexpected happens or when the origin server incorrectly interprets or does not tolerate a request due to a protocol violation or an empty response.\u00a0<\/p>
<\/p>
If\u00a0Always Online<\/em>\u00a0is enabled on your site, this status code will trigger\u00a0an Always Online page\u00a0to be served.<\/p> While it can be triggered by unique or strange edge-case scenarios, Error 520 is commonly caused by:<\/p> If you can confirm that any of the conditions above come from the origin web server hosting the site, we recommend consulting with the host provider or administrator for assistance with web server configuration to avoid further interruption and errors.<\/p> This type of error generally occurs at the application layer (OSI layer 7). This means that it results from a bad response coming back from the application.<\/p> Cloudflare Rate Limiting rules or other filtering requests (e.g., by connecting IP or volume\/frequency) may sometimes cause issues with your application. It is important to review and test these aspects of your overall configuration. Also, be sure to whitelist Cloudflare’s IPs in the origin server. See a list of\u00a0Cloudflare IP ranges.<\/p> Due to the nature of an Error 520 response, it is best to test against the origin web server. \u00a0You can use cURL and generate HTTP Archive files (HAR) as described below.<\/p> With cURL, you confirm if any of the conditions outlined above have triggered the error. This is especially true to determine if the origin server is returning an empty reply, invalid HTTP response, or extremely large response headers.<\/p> Below is an example command used to force the\u00a0Host\u00a0<\/strong>HTTP header while sending the request to the source IP address where the domain is hosted. In this example, we are sending a request for a login page:<\/p> Below is an example output where the origin response with an empty reply, which would normally trigger a 520 error if the request was proxied by Cloudflare:<\/p> A successful response header might look something like this:<\/p> Another troubleshooting task is to generate an HTTP Archive file (HAR) for a request going both direct to the origin web server and through Cloudflare. \u00a0See\u00a0How do I generate a HAR file?<\/p> HAR files are useful for comparing the response headers coming from the origin server and from Cloudflare as the proxy; for example, to confirm if the response header is too large.<\/p> If the problem persists after following the troubleshooting advice above, you can file a support ticket and include the following information:<\/p> Error 520: Web Server is Returning an Unknown Error Error 520 is essentially a catch-all response when something unexpected happens or when the origin server incorrectly interprets or does not tolerate a request due to a protocol violation or an empty response.\u00a0 If\u00a0Always Online\u00a0is enabled on your site, this status code will trigger\u00a0an Always Online …<\/p>\nCommon causes<\/strong><\/h3>
Troubleshoot Error 520<\/strong><\/h3>
Use a cURL command<\/strong><\/h3>
curl -vso \/dev\/null --user-agent \"Mozilla 5.0\" -H \"Host: example.com\" <\/pre>
* Hostname was NOT found in DNS cache\n* \u00a0\u00a0Trying 123.123.123.321...\n* Connected to 123.123.123.321 (123.123.123.321) port 80 (#0)\n> GET \/login HTTP\/1.1\n> User-Agent: Mozilla 5.0\n> Accept: *\/*\n> Host: example.com\n>\n* Empty reply from server\n* Connection #0 to host 123.123.123.321 left intact<\/pre>
* Hostname was NOT found in DNS cache\n* \u00a0\u00a0Trying 123.123.123.321...\n* Connected to 123.123.123.321 (123.123.123.321) port 80 (#0)\n> GET \/login HTTP\/1.1\n> User-Agent: Mozilla 5.0\n> Accept: *\/*\n> Host: example.com\n>\n< HTTP\/1.1 200 OK\n< Content-Type: text\/html\n< Date: Day, DD, Month Year Hour:Minute:Second Timezone\n{ [14240 bytes data]\n* Connection #0 to host 123.123.123.321 left intact<\/pre>Generate an HAR file<\/strong><\/h3>
Need additional help?<\/strong><\/h4>