Troubleshooting guide · cloudflare · Published 2026-08-15 · 3 min read

Cloudflare 521 origin refused connection

Diagnose and fix Cloudflare 521 origin refused connection. Check web server runs, port 443, firewall rules, IP binding and Cloudflare blocklists.

What 521 means

Cloudflare 521 "web server is down" means Cloudflare tried to open a TCP connection to your origin server, and the origin actively refused it. The origin is reachable on the network (no timeout, no black hole), but nothing is listening on the expected port, or something closed the connection because of a policy.

Refusal is a different failure stage than the family:

| 521 | Origin refused the connection |

| 522 | Connection timed out |

| 523 | Origin unreachable |

| 524 | Origin did not respond in time |

| 525 / 526 | TLS layer failure |

What causes 521

Ordered fixes

  1. Check status from the origin machine. Ask the host systemctl status nginx, systemctl status httpd, or the IIS console. The service can be stopped because a deploy, a reboot, or a cgroup went away.
  2. Confirm the listener:
ss -tlnp | grep 443

If nothing is listening on :443, the fix starts in the web server, not in Cloudflare. If something listens on an unusual port, fix the origin record or the bind.

  1. Resolve any firewall, security group, or iptables rule. Many hosts require allowlisting the Cloudflare edge ranges inside the security group, only for 443 and 80.
  2. Restart the service and retest. From your terminal, curl the origin IP directly while pretending to be the site hostname:
curl -v --resolve www.example.com:443:203.0.113.25 https://www.example.com/

A clean HTTP response means the origin is healthy and the remaining question is why Cloudflare cannot reach it.

  1. Check the Cloudflare IP range. If you recently switched hosting, the origin record in the dashboard may point to an IP that is no longer the server. Update the DNS record and confirm the state.
  2. Watch the origin logs. Access and error logs or the host may show reset by peer, connection refused, or a rejected handshake from the edge ranges during the incident window.

Firewall notes

Prevention

Need a website built, fixed, optimised, migrated or replaced?

This technical resource is written by CSMBAC, a small design and development studio. If you would rather hand the problem to a professional, the website service page explains how we build enquiry-ready websites.

Explore website services