Troubleshooting · Troubleshooting
How to Fix Cloudflare Error 521 on WordPress
Short answer
Cloudflare Error 521 means your origin server refused Cloudflare's connection, so visitors see a page that says the web server is down. Fix it by checking that the web server is running, allowing Cloudflare IP ranges through the origin firewall, and matching the SSL/TLS mode to the port your server listens on. If the server itself is offline, only your host can bring it back.
Key takeaways
- Error 521 means the origin server refused Cloudflare's connection, not that Cloudflare itself is down.
- Cloudflare names two main causes: an offline origin web server application and blocked Cloudflare requests.
- Flexible SSL mode connects to the origin on port 80, while Full and Full (Strict) use port 443.
- Allow every current Cloudflare IP range on ports 80 and 443, and fetch the list fresh from Cloudflare.
- A Cloudflare Origin CA certificate is valid for up to 15 years and is trusted by Cloudflare for Full (Strict) mode.
What does Cloudflare Error 521 mean?
Error 521 means Cloudflare reached your origin server, but the server refused the connection, so visitors see a page that says the web server is down.
The origin server is the server that hosts your WordPress files and database. Cloudflare sits between visitors and that server, and it forwards each request to the origin for an answer.
Cloudflare's Error 521 page states that the error occurs when the origin web server refuses connections from Cloudflare, as of November 2026. The page also notes that security tools at the origin may block real Cloudflare connections.
A refused connection is not the same as no server at all. The machine at the origin address may be running, while the web server software on it has stopped, or a firewall is turning Cloudflare away.
What causes Error 521 most often?
The two most common causes are an offline origin web server application and blocked Cloudflare requests, according to Cloudflare's Error 521 page.
Work through the causes in this order, because the first two explain most cases:
- The web server software stopped or crashed, so nothing answers on the web port.
- A firewall, security plugin, or rate limit blocked Cloudflare IP addresses.
- The SSL/TLS mode needs port 443, but the origin only listens on port 80.
- The DNS record points to an old origin IP address after a move or migration.
A failed restart after an update or a reboot is a common trigger. Check the web server first, then the firewall, then the SSL mode and the DNS record.
How can you tell Error 521 apart from 522, 520 and 525?
Error 521 means the connection was refused at once, while 522 means Cloudflare waited and got no answer, so each code points to a different fix.
| Code | Meaning | First check |
|---|---|---|
| 521 | Web server is down, connection refused | Web server running and firewall rules |
| 522 | Connection timed out | Firewall dropping packets or overloaded origin |
| 520 | Web server returns an unknown error | Origin returned an unexpected response |
| 525 | SSL handshake failed | Origin TLS setup on port 443 |
Cloudflare's 5xx errors page lists each of these codes with its own short meaning, as of November 2026. Read the number on the error page before you change any setting.
A 521 that appears at once, in under a second, fits a refused connection. If the page hangs for a long time first, check the 502 Bad Gateway guide and the timeout guides instead, because the fault sits later in the chain.
How do you check if the origin server is online?
Test the origin directly, without Cloudflare, by sending a request to the server IP address and reading the status code it returns.
- Find the origin IP in your hosting panel or in the Cloudflare dashboard DNS records.
- Send a request to that IP with curl, such as
curl -I http://203.0.113.10, using your real origin IP. - Read the status code in the reply and note whether the connection was refused.
- If the connection is refused, the web server is down and the fix sits on the origin.
Kinsta's Error 521 guide notes that an HTTP 200 response means the server is up, and a 404 response on Kinsta also means the web server is up, because no page is tied to the raw IP address. A reply of “Host Not Found” or “Failed to connect” points the other way.
If you have no SSH access, use the status page or restart option in your hosting panel. If the server stays down after a restart, contact the host with the time, the URL, and the Ray ID shown on the error page.
How do you allow Cloudflare IP addresses through the firewall?
Allow every Cloudflare IP range on ports 80 and 443 in the origin firewall, because a single blocked range can still cause 521 errors.
Cloudflare's IP addresses page explains that all traffic to a proxied record arrives from Cloudflare IP addresses, not from each visitor. That traffic can look like a small number of sources sending a high volume of requests, which may trigger automatic blocking or rate limiting.
Fetch the current lists from Cloudflare each time, instead of copying an old list from a post:
- IPv4 ranges:
https://www.cloudflare.com/ips-v4 - IPv6 ranges:
https://www.cloudflare.com/ips-v6
Cloudflare states that its IP ranges do not change often, and that changes are added to its list before they go into production, as of November 2026.
Add an allow rule for each range on ports 80 and 443, in the server firewall, the host firewall, and any cloud security group in front of the origin.
Also check tools that ban addresses on their own, such as fail2ban and WordPress security plugins. Behind Cloudflare, every request arrives from a Cloudflare address, so a ban rule aimed at one busy address can block a whole share of your visitors.
How do you fix the SSL/TLS mode and port mismatch?
Match the SSL/TLS mode to the port your origin serves: Flexible uses port 80, while Full and Full (Strict) use port 443.
| SSL/TLS mode | Cloudflare to origin | Origin port | Origin certificate |
|---|---|---|---|
| Flexible | Plain HTTP | 80 | None needed |
| Full | HTTPS | 443 | Needed, not checked |
| Full (Strict) | HTTPS | 443 | Valid certificate, checked |
Cloudflare's Error 521 page says the origin web server must be bound and listening on the port the SSL/TLS mode needs: port 80 for Flexible, or port 443 for Full and Full (Strict). If the mode is Full but the server only listens on port 80, every connection is refused.
To fix it, install a certificate on the origin and enable its port 443 listener, then set the mode to Full (Strict).
A free Cloudflare Origin CA certificate works here: Cloudflare's HTTPS setup guide says these certificates are valid for up to 15 years and are trusted by Cloudflare.
Create one under “SSL/TLS” then “Origin Server” in the dashboard.
A public certificate is the other option. Let's Encrypt states that its default certificates are valid for 90 days and recommends renewing 90-day certificates every 60 days, as of November 2026. Either way, confirm port 443 answers before you switch the mode.
For the dashboard settings, see the Cloudflare SSL settings guide.
The full walkthrough is in the Cloudflare setup guide.
How do you check the DNS record points to the right origin IP?
Open the DNS records in the Cloudflare dashboard and compare the A or AAAA record for your domain with the IP address shown in your hosting panel.
A server move, a migration, or a host change can leave an old IP in the record. That old address may belong to a dead server or to another customer, and Cloudflare will keep getting refused connections.
Fix the record to the current origin IP and keep the record proxied if you want Cloudflare in front of the site. If you recently moved hosts, confirm the new IP in the hosting panel first, because a public DNS lookup on a proxied name returns Cloudflare addresses, not your origin IP.
DNS changes take time to spread, so wait before you judge the result. See how long DNS propagation takes before you change the record a second time.
How do you know the fix worked?
Reload the site in a fresh browser tab and check that pages load, then repeat the direct origin test to confirm the server answers on the right port.
- Load the home page, one post, and the WordPress admin login page.
- Repeat the curl test against the origin IP and look for an HTTP 200 response.
- Check the Cloudflare dashboard under “HTTP Traffic” and filter by edge status code 521.
- Watch the site for a few hours, because an intermittent 521 points to a range that is still blocked.
Cloudflare's 5xx errors page notes that Error Analytics is based on a 1 percent traffic sample, as of November 2026. A falling 521 count in that view, plus pages that load, is the sign the fix held.
If a different code appears after the fix, the fault moved. A timeout after the refusal clears points to a slow or overloaded origin, so check the 504 Gateway Timeout guide next.
What mistakes should you avoid?
Do not clear caches, switch browsers, or reinstall WordPress to fix a 521, because the fault sits between Cloudflare and the origin, not in the browser.
- Copying an old IP list from a post instead of fetching the current ranges.
- Allowing only some ranges, or only IPv4, and leaving the rest blocked.
- Switching to Flexible to hide the error, which leaves origin traffic unencrypted.
- Restarting the web server without reading its error log to find why it stopped.
- Changing DNS without checking the current origin IP in the hosting panel.
Make a backup before you change firewall rules, SSL settings, or DNS records. See how to back up WordPress first, so a wrong rule can be undone in minutes.
Frequently asked questions
Can a visitor fix Cloudflare Error 521?
No. A visitor cannot fix Error 521, because it means Cloudflare was refused by the site's own origin server. Nothing in the browser, the network, or the cache caused it. The site owner or the host must restart the web server, allow Cloudflare IP ranges, or fix the SSL and DNS settings. A visitor can only wait and try again later.
Does Error 521 mean my WordPress site was hacked?
No, Error 521 on its own does not mean the site was hacked. It means the origin server refused Cloudflare's connection, which usually comes from a stopped web server, a firewall block, a port mismatch, or a wrong DNS record. Check the server status and logs first. Only treat it as a security matter if the logs show odd logins or changed files.
How long does Cloudflare Error 521 last?
Error 521 lasts until the origin fault is fixed, because Cloudflare keeps getting refused each time it tries to connect. A restart or a firewall fix can clear it in minutes. If the origin IP is wrong or the certificate is missing, it stays until the DNS record or the SSL setup is corrected. It does not clear on its own while the origin still refuses connections.
Why does Error 521 come and go instead of staying all the time?
An intermittent 521 often means only some Cloudflare IP ranges are blocked, or a tool such as fail2ban bans a Cloudflare address for a while and then lifts the ban. Visitors routed through the blocked range see the error, while others load the site. Allow every current Cloudflare range and check ban logs to find the rule that fires only sometimes.
Should I pause Cloudflare to fix Error 521?
Pausing Cloudflare, or setting the DNS record to DNS only for a short test, can help you check whether the origin answers without the proxy. Use it as a brief test, not as a fix, because the site loses Cloudflare protection while paused. If the origin loads directly but fails through Cloudflare, the fault is in the firewall, the SSL mode, or the DNS record.
Sources
- Error 521: web server is down Cloudflare Docs
- Cloudflare 5xx errors Cloudflare Docs
- Cloudflare IP addresses Cloudflare Docs
- Enforce HTTPS and encrypt all traffic Cloudflare Docs
- How to Fix Error 521 with WordPress and Cloudflare Kinsta
- Site Health: keep your website healthy WordPress.org
- FAQ Let's Encrypt
Is your product missing, or something out of date?
Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.
Thanks — we review requests within 3 business days.
