Error Codes Wiki

HTTP 520 Unknown Error (Cloudflare) — Detailed Debugging Guide

Errorcdn errors

About HTTP 520 Unknown Error (Cloudflare)

Deep dive into Cloudflare HTTP 520 Unknown Error with advanced debugging steps when the origin returns an unexpected or empty response. 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: HTTP 520 means Cloudflare received an unexpected, malformed, or empty response from the origin server. This is a catch-all error when the origin response does not conform to HTTP standards. Common causes include the origin crashing mid-response, sending oversized headers, or returning non-HTTP data. The error can be intermittent if the origin server is under load and occasionally failing. Understanding these fundamentals will help you diagnose and resolve this issue more effectively.

The most common reasons this occurs include: Origin server crashes or restarts while processing the request. Response headers from the origin exceed Cloudflare's 32KB header size limit. Origin sends a TCP RST or FIN before completing the HTTP response. Application framework returning malformed HTTP responses (missing status line, bad headers). Identifying the root cause is the first step toward finding the right solution.

To resolve this, follow these recommended steps: Check origin server error logs for crashes, memory issues, or unhandled exceptions at the time of the 520. Test the origin directly (bypassing Cloudflare) using curl -v to see the raw HTTP response. Reduce response header sizes — remove unnecessary Set-Cookie or custom headers exceeding 32KB total. Monitor origin server resources (CPU, memory, connections) for signs of overload during 520 spikes. 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

How is 520 different from 502?

A 502 means Cloudflare received an invalid response it could parse. A 520 means the response was completely unexpected — empty, non-HTTP, or the connection was dropped before any valid HTTP data arrived.

Overview

Deep dive into Cloudflare HTTP 520 Unknown Error with advanced debugging steps when the origin returns an unexpected or empty response.

Key Details

  • HTTP 520 means Cloudflare received an unexpected, malformed, or empty response from the origin server
  • This is a catch-all error when the origin response does not conform to HTTP standards
  • Common causes include the origin crashing mid-response, sending oversized headers, or returning non-HTTP data
  • The error can be intermittent if the origin server is under load and occasionally failing

Common Causes

  • Origin server crashes or restarts while processing the request
  • Response headers from the origin exceed Cloudflare's 32KB header size limit
  • Origin sends a TCP RST or FIN before completing the HTTP response
  • Application framework returning malformed HTTP responses (missing status line, bad headers)

Steps

  1. 1Check origin server error logs for crashes, memory issues, or unhandled exceptions at the time of the 520
  2. 2Test the origin directly (bypassing Cloudflare) using curl -v to see the raw HTTP response
  3. 3Reduce response header sizes — remove unnecessary Set-Cookie or custom headers exceeding 32KB total
  4. 4Monitor origin server resources (CPU, memory, connections) for signs of overload during 520 spikes

Tags

520cloudflareunknown-errororigindebugging

Related Items

More in Cdn Errors

Frequently Asked Questions

A 502 means Cloudflare received an invalid response it could parse. A 520 means the response was completely unexpected — empty, non-HTTP, or the connection was dropped before any valid HTTP data arrived.