HTTP/5xx (Server Error)
520 Web Server Returned an Unknown Error
Cloudflare-specific: the origin server returned an empty, unknown, or unexpected response.
❓ Why does this happen?
Origin crashed, reset the connection, or sent headers exceeding Cloudflare's 32 KB limit.
✅ How to fix it
Check origin server error logs, disable firewall rules blocking Cloudflare IPs, and reduce response header size.
Return or handle 520 in your stack
// Note: 520 is normally generated by Cloudflare, not your app.
// Emitting it yourself is only useful for testing client error handling.
// app/api/resource/route.ts
export function GET() {
return Response.json(
{ error: "Web Server Returned an Unknown Error", status: 520 },
{
status: 520
}
);
}Live 520 mock endpoint
Point your app, tests, or retry logic at this free public URL to reproduce a real 520 response (CORS enabled, optional ?delay=ms up to 5000).
https://castov.com/api/mock/520520 vs similar status codes
Frequently Asked Questions
What does HTTP Status 520 mean?
Why am I getting a 520 status code?
How do I fix a 520 Web Server Returned an Unknown Error error?
What is the difference between 520 Web Server Returned an Unknown Error and 502 Bad Gateway?
How can I test how my app handles a 520 response?
Other 5xx status codes
Browse the full HTTP status codes directory or troubleshoot terminal errors in the Error Fix Encyclopedia.