Troubleshooting · Troubleshooting
How to Fix Cloudflare Error 520 on WordPress
Short answer
To fix Cloudflare Error 520 on WordPress, find the fault at your origin server, because Cloudflare reached it but got an empty or invalid reply. Check the origin error logs at the time shown by the cf-ray ID, test the origin with Cloudflare paused, trim response headers below 128 KB, and allow Cloudflare IPs at your firewall. If the error continues, send Cloudflare Support the cf-ray ID, the failing URLs, and two HAR files.
Key takeaways
- Error 520 means Cloudflare reached your origin but got an empty, unknown, or unexpected response it could not pass on.
- Response headers over 128 KB, often from too many cookies, are a common cause on WordPress sites.
- The cf-ray ID on the error page plus the exact time lets your host find the crash in the origin logs.
- Switching a record to DNS-only tells you in minutes whether the fault is at the origin or in the Cloudflare path.
- HTTP/2 to Origin lives under Speed > Settings > Protocol Optimization, and turning it off is a fast test.
- Cloudflare Support needs the full URLs, the cf-ray ID, /cdn-cgi/trace output, and two HAR files.
What does Cloudflare Error 520 mean?
Error 520 means Cloudflare reached your origin server but received an empty, unknown, or unexpected response it could not pass on.
Cloudflare's Error 520 page gives that exact definition, and the page was updated on June 16, 2026 (checked November 2026). The origin server is the server at your host where WordPress runs.
The error page a visitor sees reads “Web server is returning an unknown error” and shows a Ray ID at the bottom. That Ray ID, called cf-ray, identifies the exact failed request.
A 520 is an origin problem, not a visitor problem. Clearing a browser cache or switching networks will not fix it, because the broken reply comes from the server.
How is Error 520 different from Error 521 and Error 522?
Error 520 means the origin answered badly, while 521 means it refused the connection and 522 means it took too long to answer.
| Code | What Cloudflare found | Usual place to look |
|---|---|---|
| 520 | Empty, unknown, or unexpected response | Origin error logs and headers |
| 521 | Connection refused by the origin | Server down, wrong port, firewall reject |
| 522 | Connection timed out | Overloaded or unreachable origin |
Cloudflare groups these as its own 5xx errors, and each code points at a different step in the trip between Cloudflare and your origin. Matching the code to the step saves hours of guessing.
A related server error is the 502 Bad Gateway, covered in our 502 Bad Gateway guide. A 502 means a gateway got an invalid reply, while a 520 means Cloudflare got a reply it could not read at all.
What causes Cloudflare Error 520 on WordPress?
Cloudflare lists 7 common causes, starting with origin crashes, blocked Cloudflare IPs, headers over 128 KB, and empty or malformed responses.
- Origin server crashes or misconfigurations, including a PHP application that crashes mid-request.
- Firewalls or security plugins blocking Cloudflare IPs at the origin.
- Response headers over 128 KB, often from too many or too large cookies.
- Empty or malformed responses with no HTTP status code or body.
- Missing response headers, or no proper HTTP error response from the origin.
- Incorrect HTTP/2 setup at the origin server.
- Authenticated Origin Pulls turned on at Cloudflare but not set up at the origin.
On WordPress, a crash often starts in PHP. Kinsta's 520 guide notes that a crashed PHP application is a common trigger, and restarting PHP fixes it when that is the cause.
Headers deserve special attention on WordPress sites with many plugins. Each plugin can add cookies or headers, and the total can pass 128 KB on logged-in pages even when the home page loads fine.
How do you find the exact cause of a 520 error?
Copy the cf-ray ID from the error page, note the exact time, and search your origin error logs for that same minute.
- Copy the cf-ray ID and the full URL of the failing page.
- Open your origin error log in your hosting panel and look at entries from that minute.
- Look for crashes, out-of-memory kills, segfaults, or “connection reset by peer” lines.
- Turn on WordPress logging if the log shows nothing useful.
WordPress logging uses constants in wp-config.php. The WordPress debugging handbook explains that WP_DEBUG_LOG set to true writes errors to a debug.log file in your /wp-content directory.
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
Keep WP_DEBUG_DISPLAY false on a live site so errors go to the file instead of the screen. Delete debug.log and turn WP_DEBUG off when you finish.
Cloudflare's own logs can narrow it down too. Its 520 page explains that OriginResponseStatus 0 with CacheStatus miss means Cloudflare contacted the origin and got no usable reply, while the same value with a cache hit means no origin contact at all.
Origin Analytics compares originResponseStatus with edgeResponseStatus. If the origin returned 200 but Cloudflare served 520, the reply was likely malformed, for example from oversized headers or an early connection close.
How do you test your origin server without Cloudflare?
Switch the DNS record to DNS-only, with the gray cloud, or pause Cloudflare, then load the site and repeat the failing request.
Kinsta's guide recommends disabling Cloudflare first so you can tell whether the fault survives without it. In the Cloudflare dashboard, open the DNS tab and click the orange cloud under Proxy status until it turns gray.
If the page still fails with Cloudflare off, the fault is at the origin, and your host needs the log entries. If the page works with Cloudflare off but fails with it on, the fault sits in the Cloudflare-to-origin path.
A curl test against the origin gives the same answer without touching DNS. Use curl --resolve with your domain, port 443, and your origin IP to send the request straight to the server.
Cloudflare also asks for 2 HAR files when a case reaches support: one recorded with Cloudflare on and one with it off. A HAR file is an HTTP archive that records every request your browser made.
If you are new to these settings, our Cloudflare setup guide explains the dashboard layout and the settings that matter for WordPress.
How do you fix oversized response headers and cookies?
Reduce response headers below 128 KB by removing unneeded cookies and debug headers, then retest the page.
Cloudflare's 520 page names headers over 128 KB as a common cause and notes that excessive cookies are often behind it. WordPress plugins, consent banners, and analytics tools can each add cookies.
- List the Set-Cookie headers on the failing page and remove cookies nothing reads.
- Move large session data to server-side storage instead of cookies.
- Drop debug headers on live pages.
- Ask users who see the error to clear cookies for your site, then sign in again.
Test logged-in pages separately from public pages. Cookie headers grow after sign-in, so a 520 that only hits members or checkout pages points at headers first.
How do you allow Cloudflare IPs at your origin?
Add Cloudflare's published IP ranges to your origin firewall allowlist so its requests are never blocked or rate-limited.
All traffic to a proxied record passes through Cloudflare, so your origin sees Cloudflare addresses instead of visitor addresses. Cloudflare's IP addresses page lists the current ranges and says to allow them at the origin.
Fetch the lists from Cloudflare itself at cloudflare.com/ips, with plain-text copies at /ips-v4 and /ips-v6, as of November 2026. Do not paste ranges from an old post, because Cloudflare adds ranges to the list before they go live and a stale list blocks real traffic.
If you run your own firewall, allow the ranges on ports 80 and 443. Cloudflare's page shows an iptables example that accepts TCP traffic on http and https from each range.
On managed WordPress hosting, ask support to allow Cloudflare IPs instead of editing firewall rules yourself. Tell them the 520 started after a firewall or security plugin change if that timing fits.
How do you fix HTTP/2 and Authenticated Origin Pulls problems?
Turn off HTTP/2 to Origin in Speed > Settings > Protocol Optimization to test it, and check that Authenticated Origin Pulls matches your origin setup.
Cloudflare connects with HTTP/2 when the origin announces support through ALPN. If the origin accepts the connection but does not handle the protocol, Cloudflare returns a 520, so disabling the setting is a fast test.
If the error stops with HTTP/2 to Origin off, leave it off and ask your host to fix the origin HTTP/2 setup. If nothing changes, turn the setting back on and keep working down the list.
Authenticated Origin Pulls, or AOP, makes the origin accept only requests that present a Cloudflare client certificate. Cloudflare's AOP docs explain that it adds a check on top of Full or Full (strict) encryption.
The mismatch that causes a 520 is simple: AOP is on at Cloudflare, but the origin is not set up to check the certificate. Turn AOP off to test, then set up the origin side before turning it on again.
Our Cloudflare SSL settings guide covers the encryption modes that AOP depends on.
How do you check that the 520 error is fixed?
Reload the failing pages through Cloudflare several times and confirm they return a 200 status instead of 520.
- Load the exact URLs that failed, including logged-in and form pages.
- Check Origin Analytics for fresh 520 entries over the next hour.
- Ask a second person or a different network to load the site.
- Watch the origin error log for new crashes at the same times.
Intermittent 520s need a longer watch than a single reload. A crash that happens once an hour will pass a quick check and return later, so give it a full day before you call it fixed.
If the error changes into a timeout instead, the cause has moved. Our 504 Gateway Timeout guide covers that next step.
When should you contact your host or Cloudflare Support?
Contact your host when logs show crashes or resets you cannot fix, and contact Cloudflare Support with the cf-ray ID if the 520 continues.
Cloudflare's resolution steps start with the host: share the error details and ask for a review of the origin web server error logs for crashes. That review is the step most owners skip.
If the host finds nothing and the error continues, Cloudflare Support asks for 4 items: the full URLs, the cf-ray from the error page, the output of /cdn-cgi/trace for your domain, and 2 HAR files.
Send the exact cf-ray from a fresh error, not one from yesterday. Each Ray ID maps to one request, so an old ID points support at the wrong log entries.
What mistakes should you avoid?
Do not edit live files without a backup, leave debug display on, or treat turning Cloudflare off as a fix.
- Do not leave WP_DEBUG_DISPLAY true on a live site, because errors print on the page for every visitor.
- Do not leave Cloudflare paused or DNS-only as a permanent fix, because you lose its protection and the origin fault stays.
- Do not allowlist only part of Cloudflare's IP ranges, because traffic from a missing range still gets blocked.
- Do not copy IP ranges from an old article instead of cloudflare.com/ips.
- Do not skip the logged-in pages when you test, because cookie-driven 520s hide on public pages.
Back up before you touch wp-config.php or firewall rules. Our WordPress backup guide shows the steps, and a backup turns a bad edit into a short restore.
Frequently asked questions
Can a visitor fix Cloudflare Error 520?
No. Error 520 comes from the website's origin server, so only the site owner or the host can fix it. A visitor can retry the page later, clear cookies for that site, and report the problem to the site owner with the Ray ID from the error page.
Does Error 520 mean my WordPress site is down?
Not always. The origin server may answer direct requests fine while the path through Cloudflare fails. Test the site with Cloudflare paused or DNS-only: if it loads then, the site itself runs and the fault is in the Cloudflare-to-origin connection.
Why does Error 520 only appear on some pages?
Some pages send larger headers than others, often because of login cookies, cart data, or plugin output. A page that works for logged-out visitors can fail for logged-in users when cookies push headers over 128 KB, or when one PHP process crashes on that page only.
How long does it take to fix Error 520?
It depends on the cause. Trimming oversized cookies or turning off a bad HTTP/2 setting can fix it in minutes. A crashing PHP process or a firewall rule at the host can take longer, because the host must find the crash in the logs and fix the server setup.
Should I just turn off Cloudflare to fix Error 520?
No. Turning Cloudflare off is a diagnostic step, not a fix. It tells you whether the fault is at the origin, but it leaves the site without Cloudflare protection and the origin fault still in place. Fix the origin problem, then turn the proxy back on.
What is the cf-ray ID on the Error 520 page?
The cf-ray ID is a unique code Cloudflare adds to every request and prints on the error page. It lets your host and Cloudflare Support find that exact request in the logs. Always send the ID from a fresh error, with the exact time and the full URL.
Sources
- Error 520: web server returns an unknown error Cloudflare Support docs
- Cloudflare IP addresses Cloudflare Docs
- Authenticated Origin Pulls (mTLS) Cloudflare Docs
- Debugging in WordPress WordPress Developer Resources
- How to Fix Error 520: Web Server Is Returning an Unknown Error Kinsta
- How to Fix Cloudflare Error 520 Hostinger Tutorials
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.
