Skip to main content
HTTP/5xx (Server Error)

521 Web Server Is Down

Cloudflare-specific: the origin server refused the connection from Cloudflare.

❓ Why does this happen?

The web server process is stopped, or a firewall blocks Cloudflare's IP ranges.

✅ How to fix it

Start the web server (systemctl start nginx) and allow-list Cloudflare IP ranges in your firewall.

Return or handle 521 in your stack

// Note: 521 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 Is Down", status: 521 },
    {
      status: 521
    }
  );
}

Live 521 mock endpoint

Point your app, tests, or retry logic at this free public URL to reproduce a real 521 response (CORS enabled, optional ?delay=ms up to 5000).

https://castov.com/api/mock/521

Frequently Asked Questions

What does HTTP Status 521 mean?
Cloudflare-specific: the origin server refused the connection from Cloudflare.
Why am I getting a 521 status code?
The web server process is stopped, or a firewall blocks Cloudflare's IP ranges.
How do I fix a 521 Web Server Is Down error?
Start the web server (systemctl start nginx) and allow-list Cloudflare IP ranges in your firewall.
How can I test how my app handles a 521 response?
Send a request to https://castov.com/api/mock/521 — it returns a real 521 Web Server Is Down response with CORS enabled. Add ?delay=2000 to simulate a slow server.

Other 5xx status codes

Browse the full HTTP status codes directory or troubleshoot terminal errors in the Error Fix Encyclopedia.