Troubleshooting

How to fix Cloudflare Error 520: Web server is returning an unknown error

Cloudflare Error 520 means your origin server sent an empty, invalid or unexpected response. Learn the usual causes on hosting and how to fix error 520 step by step.

IntermediatecPanel hosting2 min read

Cloudflare Error 520 ("Web server is returning an unknown error") is Cloudflare's catch-all: it reached your origin server, but the reply was empty, malformed or cut off. Because Cloudflare does not know what went wrong, you need to test the origin server directly to find the real cause.

Before you start

  • Your origin server IP (in cPanel → General Information, or the Cloudflare DNS record).
  • Access to cPanel and the Cloudflare dashboard.

Common causes of Cloudflare Error 520

  • The application crashed mid-response, such as a PHP fatal error that closed the connection.
  • Response headers too large – Cloudflare rejects headers over roughly 128 KB, often from huge cookies.
  • A firewall resetting Cloudflare connections, for example after rate limiting Cloudflare IPs.
  • An empty response from a misconfigured web server or a script that exits without output.

How to fix error 520

  1. Bypass Cloudflare. Test the origin with curl -svk --resolve example.com:443:ORIGIN_IP https://example.com/. If it fails or returns nothing, the problem is on the server.
  2. Check the error log. In cPanel → Metrics → Errors look for PHP fatal errors or segmentation faults at the times of the 520. Fix the plugin or script involved.
  3. Check header size. In the curl output, look for a very long Set-Cookie list. Reduce cookies the site sets, especially from plugins.
  4. Allow Cloudflare IPs. Make sure the server firewall is not blocking or throttling Cloudflare's IP ranges. On MdmHost hosting, open a ticket and support will check the firewall.
  5. Pause Cloudflare briefly (Overview → Pause Cloudflare on Site) to confirm the site works without it, then re-enable it.

Tip: Cloudflare shows a Ray ID on the error page. Keep it with the exact time – it makes a support ticket much faster to resolve.

What to check afterwards

Reload the site through Cloudflare several times and check that no new errors appear in the origin's log.

FAQ

Is error 520 Cloudflare's fault?

Rarely. It means the origin sent something Cloudflare could not use.

Why does 520 only happen on some pages?

Those pages likely trigger a PHP error or set large cookies. Compare them in the error log.

Should I turn off Cloudflare?

Only to diagnose. Pausing it shows whether the origin is healthy.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.