Skip to content
Log In Sign Up info@muvcloud.com

What Error 520 Means

With a proxied site, the edge opens a connection to your origin and forwards the visitor's request. Error 520 means the origin answered in a way the edge did not expect: it closed or reset the connection without a response, sent an empty reply, or sent headers the edge could not accept. The other codes are more specific: 521 for a refused connection, 522 for a connection that timed out, and 524 for a response that did not arrive in time.

If You See It on Someone Else's Site

  • Reload once: a 520 during a restart of the site's server can clear quickly.
  • Nothing in your browser causes it: clearing the cache does not change the result.
  • Tell the site owner the time and the Ray ID from the error page; they can find the request in their logs with it.

Read the Origin Logs

sudo tail -n 50 /var/log/nginx/error.log

Reproduce the error and look at the same minute. Messages that an upstream "prematurely closed connection" or that a read failed with "Connection reset by peer" mean the application behind Nginx dropped the request. A PHP-FPM log line saying a child "exited on signal" means a PHP worker crashed. Apache writes to /var/log/apache2/error.log on Debian and Ubuntu and /var/log/httpd/error_log on AlmaLinux and Rocky Linux.

Cloudflare sends the Ray ID to the origin as a CF-Ray request header. Logging it lets you match a visitor's error page to one log line:

log_format cfray '$remote_addr [$time_local] "$request" $status $http_cf_ray';
access_log /var/log/nginx/cfray.log cfray;

Test the Origin Directly

Skip the CDN and send the request to the server's IP with the right host name:

curl -v --resolve example.com:443:203.0.113.10 https://example.com/

A status line and headers mean the origin answers normally for this page; test the exact address that fails. An "Empty reply from server" message, or a reset, reproduces the 520 without the CDN. Run it from a machine your firewall allows.

A Crashed or Restarting Backend

When the application process dies in the middle of a request, the connection closes with nothing sent. Check the service and the kernel log for memory kills:

systemctl status your-app
sudo journalctl -k | grep -i oom

Replace your-app with the service name. A process stopped by the out-of-memory killer needs more memory or a lower worker count; a crash on one page needs the application log and a code fix.

Oversized Response Headers

The edge has a limit on the size of response headers; Cloudflare's 520 page names headers over 128 KB, often caused by too many cookies. A page that sets dozens of cookies, or sends a very long security policy header, can reach it. Measure what the origin sends:

curl -s -o /dev/null -D - --resolve example.com:443:203.0.113.10 https://example.com/ | wc -c

The result is the header size in bytes. If it is far larger than on a normal page, reduce the number and size of Set-Cookie headers and move long policies into shorter forms.

Rules That Close Connections

  • Nginx return 444: this non-standard code closes the connection without sending a response header. A rule that blocks by user agent or host name and matches edge requests produces a 520.
  • Firewall resets: a rule that rejects edge addresses with a TCP reset in the middle of a connection, or a rate limiter that does the same, cuts responses off.
  • Security modules: a web application firewall that drops requests instead of answering them gives the same result.

Allow the CDN's published address ranges in such rules, as described in error 522.

Confirm the Fix

curl -I https://example.com/

Expect 200 and a cf-ray header. If the origin now answers with a 5xx code of its own, see 500 Internal Server Error.

Updated:

Linux VPS with Full Root Access

MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.

Cloud VPS Plans Starting at2.99 $/mo Cheap Linux VPS

No Limits on Service or Support

You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

Support specialist
  • 100% customer satisfaction goal
  • Our own hardware
  • 24/7 ticket and email support
  • 4 countries with locations