Error Codes Wiki

HTTP 520 Cloudflare — Web Server Returned an Unknown Error

Error5xx server error

About HTTP 520 Cloudflare

Cloudflare error 520 means the origin web server returned an unexpected or empty response that Cloudflare could not process. This guide covers everything you need to know about this topic, including common causes, step-by-step solutions, and answers to frequently asked questions.

Here are the key things to understand: 520 is a Cloudflare-specific status code, not part of standard HTTP. Cloudflare received a connection but got an invalid or empty response. The origin server established TCP connection but sent no HTTP response. Common with misconfigured origin servers or applications crashing on request. Different from 522 (connection timeout) and 524 (timeout on response). Understanding these fundamentals will help you diagnose and resolve this issue more effectively.

The most common reasons this occurs include: Origin server crashed or sent a malformed response. Origin server PHP/application error returning empty response. Cloudflare IP addresses not whitelisted on origin server firewall. Response headers from origin exceed Cloudflare's 32 KB header buffer. Origin server closing the connection before sending a complete response. Identifying the root cause is the first step toward finding the right solution.

To resolve this, follow these recommended steps: Check origin server logs (Apache/nginx error log) for crashes or errors at the time of the 520. Whitelist all Cloudflare IP ranges on the origin server firewall (cloudflare.com/ips). Reduce response header size if exceeding 32 KB (large Set-Cookie headers are common). Test origin directly (bypass Cloudflare) to see if the server responds correctly. Check if the origin application is crashing: PHP, Node, Python error logs. If these steps do not resolve the issue, consider consulting additional resources or a qualified professional.

This article is part of our HTTP Status Codes collection on Error Codes Wiki. We provide comprehensive, up-to-date information to help you find solutions quickly.

Quick Answer

Is this a Cloudflare problem or my server?

Almost always your origin server. 520 means Cloudflare connected to your server but received an invalid or empty response.

Overview

Cloudflare error 520 means the origin web server returned an unexpected or empty response that Cloudflare could not process.

Key Details

  • 520 is a Cloudflare-specific status code, not part of standard HTTP
  • Cloudflare received a connection but got an invalid or empty response
  • The origin server established TCP connection but sent no HTTP response
  • Common with misconfigured origin servers or applications crashing on request
  • Different from 522 (connection timeout) and 524 (timeout on response)

Common Causes

  • Origin server crashed or sent a malformed response
  • Origin server PHP/application error returning empty response
  • Cloudflare IP addresses not whitelisted on origin server firewall
  • Response headers from origin exceed Cloudflare's 32 KB header buffer
  • Origin server closing the connection before sending a complete response

Steps

  1. 1Check origin server logs (Apache/nginx error log) for crashes or errors at the time of the 520
  2. 2Whitelist all Cloudflare IP ranges on the origin server firewall (cloudflare.com/ips)
  3. 3Reduce response header size if exceeding 32 KB (large Set-Cookie headers are common)
  4. 4Test origin directly (bypass Cloudflare) to see if the server responds correctly
  5. 5Check if the origin application is crashing: PHP, Node, Python error logs

Tags

http520cloudflareorigin-errorcdn

More in 5xx Server Error

Frequently Asked Questions

Almost always your origin server. 520 means Cloudflare connected to your server but received an invalid or empty response.