Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk10 min

How to Fix Cloudflare Error 521 on Your Own Server

Cloudflare Error 521 means your origin refused Cloudflare’s connection. Follow this practical sequence to check the server, listener ports, SSL/TLS mode, DNS, firewalls and load balancers.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Cloudflare Error 521 means Cloudflare reached your hostname but the origin web server refused the connection. The fix is normally at the origin: bring the web service back online, make sure it is listening on the port selected by your Cloudflare SSL/TLS mode, and allow Cloudflare’s current IP ranges through every firewall, proxy and security tool. Check the path in order rather than repeatedly changing Cloudflare settings.

  • For Flexible SSL/TLS, the origin must accept HTTP on port 80.
  • For Full or Full (Strict), the origin must support HTTPS and accept connections on port 443.
  • Record the exact URL, time and timezone, and error details before making changes so you can correlate them with server and Cloudflare logs.

What Error 521 means

Cloudflare describes Error 521 as occurring when “the origin web server refuses connections from Cloudflare.” Cloudflare is acting as the reverse proxy: a visitor connects to Cloudflare, and Cloudflare then opens a separate connection to your server. A 521 is generated when that second connection is actively refused or rejected.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

This is different from an application returning an ordinary HTTP error. Your web server may be powered on while its web process is stopped, listening only on a private interface, bound to the wrong port, or rejecting Cloudflare’s source addresses. A load balancer, reverse proxy, hosting firewall, intrusion-prevention tool or security plugin can also refuse the connection before it reaches the application. Cloudflare identifies an offline origin web-server application and blocked Cloudflare requests as its two most common causes.

Do not assume that a successful request from your laptop proves the origin is healthy. Your laptop may reach a different address, a cached page, or an unprotected management path, while Cloudflare is sent to another address or blocked at the edge of your network.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

Capture the failure before changing anything

Write down the complete failure context. It makes intermittent problems much easier to match with logs and avoids losing evidence when a restart clears a useful message.

  • The exact 521 page and HTTP status.
  • The failing hostname and full URL, including the path.
  • The first and most recent occurrence, with the timezone.
  • Whether every URL fails or only one hostname, path or protocol.
  • Any Cloudflare Error Analytics fields available for the event, including URL, source IP and data center.

Cloudflare says its Error Analytics view is based on a 1% traffic sample. That means the dashboard can confirm a pattern without containing every failed request. Preserve your own web-server, load-balancer and firewall timestamps as the authoritative detail for an individual incident.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Follow this troubleshooting sequence

1. Confirm that the origin host and web service are online

Check the virtual machine or physical server first. Confirm that it has power or is in a running state, that its network interface is up, and that it has not exhausted memory, disk space or connection limits. A host that is booted but out of resources may leave the web process unable to accept new connections.

On a Linux system, inspect the service that owns your site. Replace the service name with the one used by your installation:

sudo systemctl status nginx
sudo systemctl status apache2
sudo journalctl -u nginx --since "30 minutes ago"

For a different web server, use its service name and log location. Look for a stopped process, a crash loop, a configuration error after a deployment, or messages about file descriptors, memory and address binding. Restart only after checking the recent status and logs; an immediate restart can hide the original failure.

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.

If the service is stopped and the configuration test fails, correct the configuration first. If it starts successfully, request the site again and continue checking the remaining layers even if the 521 disappears. A process that repeatedly stops is a capacity or application problem, not a durable Cloudflare fix.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

2. Verify the listener and the interface it uses

A running process can still refuse Cloudflare if it listens on the wrong port or only on a loopback or private address. Check listening sockets and the process that owns them:

sudo ss -ltnp | grep -E ':80|:443'

You should see the port required by your SSL/TLS mode and an interface reachable from the network path. A listener on 127.0.0.1 accepts requests only from the same host; a public-facing reverse proxy normally needs to bind to the server’s reachable address or to all intended interfaces. Verify the host’s local and provider-level firewall rules as well as the process binding.

Test the origin locally, using the correct Host header so virtual-host routing is exercised:

curl -I http://127.0.0.1 -H 'Host: example.com'
curl -k -I https://127.0.0.1 -H 'Host: example.com'

Replace example.com and the protocol with your hostname and configuration. A successful local response proves that something is serving locally; it does not prove that Cloudflare can reach the public interface. A connection refusal locally points to the service or listener. A local success followed by a 521 usually moves the investigation toward DNS, routing or filtering.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

3. Match Cloudflare’s SSL/TLS mode to the origin

Cloudflare’s connection to your server depends on the mode selected in the dashboard. Use this mapping when checking listeners:

Cloudflare SSL/TLS mode Connection Cloudflare makes to the origin Origin requirement Typical mismatch
Flexible HTTP Accept HTTP on port 80 Only HTTPS is listening, so port 80 refuses or has no service
Full HTTPS Support HTTPS and listen on port 443 Port 443 is closed, unbound or handled by the wrong virtual host
Full (Strict) HTTPS Support HTTPS on port 443 with the certificate and TLS setup required for strict validation HTTPS is absent or the certificate configuration is not suitable for strict mode

Cloudflare documents port 80 for Flexible and port 443 for Full and Full (Strict). Do not change the mode blindly: choose the mode that matches the protocol your origin is actually configured to serve, then correct the listener or certificate setup if it does not. After changing a mode or listener, test both the hostname and the origin’s direct endpoint, where your hosting provider permits that test.

4. Check web-server and intermediary logs together

Search the web-server access and error logs for the recorded minute, then check every component in front of it. Cloudflare warns that the cause may not appear in origin logs alone. Review:

  • A cloud or hardware load balancer and its target-health events.
  • A reverse proxy or caching tier between Cloudflare and the application.
  • The host firewall and any provider security group.
  • Intrusion-prevention, bot-protection and fail2ban-like tools.
  • Container, orchestration or service-mesh routing if the web server is not running directly on the host.

If the web-server log has no entry at the time of a 521, the request was probably rejected earlier, sent to a different address, or never reached that machine. Compare the destination address in DNS with the address whose logs you are reading. If an intermediary records the refusal, fix that layer rather than adding an application rule that cannot be reached.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

5. Allow Cloudflare at every security layer

Cloudflare’s requests originate from Cloudflare’s published IP ranges, not from the visitor’s address. Ensure that all current Cloudflare IPv4 and IPv6 ranges are permitted at the hosting firewall, operating-system firewall, load balancer, reverse proxy, web-server access rules and security plugins. Use Cloudflare’s current list rather than copying an old blog post; ranges can change.

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

Look for explicit deny rules, connection-rate limits, geographic blocks and automated bans. A fail2ban-like tool may have interpreted normal Cloudflare traffic as abusive and banned an entire Cloudflare range. Remove the stale ban and adjust the rule so legitimate Cloudflare addresses are not scored as individual attackers. If you use an allowlist, place the Cloudflare ranges in the allow rule before a broad deny rule and preserve IPv6 coverage.

Do not allow only the address shown in a browser test. The visitor’s source IP is normally carried in headers by Cloudflare and is not the network source that your firewall must permit. Restrict administrative ports separately; allowing Cloudflare to reach the web ports does not require opening SSH or other management services.

6. Verify DNS points to the intended origin

In Cloudflare DNS, confirm that the proxied hostname resolves to the current public address of the server or load balancer that is meant to serve it. Check both the record value and the hostname being requested. If the server was migrated recently, a stale record can send Cloudflare to an old machine whose port is closed, producing a convincing 521 while the new server appears healthy.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Also check whether the service is bound to the address in the record. A record can be correct while the operating system listens on a different interface, or while a provider firewall exposes a different public address than the one you entered. Correct the record or binding before spending time on application settings. Allow DNS changes to propagate according to the record’s TTL, then retest the same URL.

7. Check capacity and recurring refusal patterns

If the origin works briefly and then returns 521 under load, inspect connection counts, worker limits, memory, CPU, file descriptors and upstream health. A web process that has reached its worker or socket limit can refuse new connections even though its service manager reports it as running. A load balancer may mark every backend unhealthy when health checks use the wrong port or Host header.

Separate a one-time configuration error from a recurring capacity problem. A corrected allowlist, listener or DNS record is a one-time change. Repeated refusals after traffic spikes call for capacity planning, health-check correction, process limits or managed server monitoring; repeatedly restarting the service only resets the symptom.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choose the remedy that matches the evidence

Evidence Likely layer Action What to verify afterward
Service is stopped or crash-looping Origin application or host Read recent logs, fix the configuration or resource fault, then start the service Process remains running and serves the expected Host header
No listener on the required port Web-server binding or SSL setup Configure the correct port and reachable interface; reload after a successful configuration test Port 80 or 443 matches the selected Cloudflare mode
Listener works locally, but no origin log entry exists DNS, routing, firewall or intermediary Correct the destination address and inspect provider, host and proxy rules The request appears in the first reachable component’s logs
Firewall or security tool shows a Cloudflare-range block Filtering or automated banning Remove the ban and allow current Cloudflare ranges before broad deny rules New requests pass without disabling unrelated protections
Failures correlate with traffic peaks Capacity, worker or backend health Increase capacity or correct health checks and limits Connections remain accepted during the same traffic pattern

Validate the repair without creating a new outage

  1. Confirm the origin service is stable for several minutes and that its error log is not filling with new binding, TLS or resource errors.
  2. Request the hostname over the protocol visitors use. Test a representative page and a lightweight health endpoint if your application has one.
  3. Check the web-server, proxy, load-balancer and firewall logs for the request. Confirm it arrived through the expected path and was not served by an unintended backend.
  4. Repeat from more than one network or use Cloudflare’s analytics view to check whether 521 events are declining. Remember that Error Analytics represents a 1% traffic sample, so it is a trend signal rather than a complete request ledger.
  5. Recheck after the next deployment, firewall-rule reload or automatic-ban interval. A temporary success after a restart is not proof that the underlying cause is gone.

Keep a dated record of the setting changed, the old value, the test URL and the observed result. It gives you a safe rollback point and lets a host or site administrator distinguish a DNS correction from a recurring server failure.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When you need to escalate

Contact the host, site administrator or infrastructure team when you cannot access the machine, a provider firewall is refusing traffic, the load balancer reports unhealthy targets, or the web service continues to crash after its configuration is corrected. Send a compact incident record:

  • The 521 status and the exact failing URL.
  • Occurrence time and timezone, including a range for intermittent failures.
  • The origin address and Cloudflare hostname involved.
  • Relevant web-server, proxy, load-balancer and firewall log lines.
  • Cloudflare Error Analytics details such as URL, source IP and data center, noting that the analytics view is based on a 1% sample.
  • Which SSL/TLS mode is selected and whether the origin is listening on port 80 or 443.

Do not send passwords, private keys or complete customer databases in a support ticket. Redact secrets while retaining timestamps, status codes and rule identifiers that let the administrator trace the refusal.

Prevent the next 521

  • Monitor the web process, listener ports, certificate expiry and backend health instead of monitoring only the public page.
  • Keep Cloudflare IP allowlists maintained at the firewall, load balancer, proxy and application-security layers.
  • Make SSL/TLS mode, origin ports and certificate requirements part of the deployment checklist.
  • Alert on worker exhaustion, memory pressure, connection limits and repeated service restarts.
  • Record DNS changes and the intended origin address so a migration cannot silently leave Cloudflare pointing at an old host.
  • Retain logs long enough to cover the time window in which a 521 was reported, including timezone information.

Frequently Asked Questions

Does Error 521 always mean the physical server is powered off?

No. It means the origin refused Cloudflare’s connection. The host may be online while the web process is stopped, listening on another port, bound to an unreachable interface, or blocked by a firewall or intermediary.

Which port should Cloudflare use?

Flexible mode requires the origin to accept HTTP on port 80. Full and Full (Strict) require HTTPS on port 443. A listener and SSL/TLS mode that do not match can produce a 521.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why does the site work when I test the server directly but fail through Cloudflare?

A direct test may use a different address or bypass a firewall, proxy or load balancer. Check the DNS destination, Cloudflare-range allowlists and every intermediary’s logs for the same timestamp.

Can I fix a 521 by allowing the visitor’s IP address?

Usually not. The network connection to your origin comes from Cloudflare’s IP ranges. Allow the current Cloudflare ranges at each security layer while keeping administrative ports protected.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.