Overview

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.

If Always Online is enabled on your site, this status code will trigger an Always Online page to be served.

Common causes

While it can be triggered by unique or strange edge-case scenarios, Error 520 is commonly caused by:

Connection resets after a successful TCP handshake

Headers that exceed Cloudflare’s header size limit (8kb)

An empty response from the origin server

An invalid HTTP response

An HTTP response without response headers

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.

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.

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 Cloudflare IP ranges.

Troubleshoot Error 520

Due to the nature of an Error 520 response, it is best to test against the origin web server. You can use cURL and generate HTTP Archive files (HAR) as described below.

Use a cURL command

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.

Below is an example command used to force the Host 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: