Error type: Cloudflare Origin Error
Error code: 520
Also appears as: “Error 520: Web Server Returns an Unknown Error”
What is a Cloudflare 520 error?
A 520 error means that Cloudflare successfully connected to your web server, but the response it received back was empty, invalid, or didn’t follow standard HTTP protocols. Rather than pass a broken response on to your visitor, Cloudflare returns a 520 error page instead.
In short: your server is responding, but not in a way that Cloudflare can interpret or pass on.
Is a 520 error the same as my site being down?
Not necessarily. Your web server may still be running, but something is causing it to return an unusable response. The distinction matters because it changes where you need to look to fix the problem.
For reference, here’s how 520 relates to similar Cloudflare errors:
- 520 — Server responded, but with something invalid or empty
- 521 — Server actively refused the connection
- 522 — Connection timed out before a response was received
- 523 — Cloudflare cannot reach the origin server at all
What causes a 520 error?
There are several common causes. The most frequently seen are:
Empty response from the server
The server sent back a completely blank reply — no headers, no content. This often happens when a PHP script crashes mid-execution before sending any output to the browser.
PHP or application fatal error
A broken plugin, a failed update, or a theme conflict can cause WordPress (or another PHP application) to throw a fatal error. On a live site with error display turned off, the server may return nothing useful — triggering the 520.
Invalid or oversized response headers
HTTP response headers must follow a specific format. If your server sends headers that are malformed or unusually large, Cloudflare will reject them and return a 520.
Server resource limits being exceeded
Running out of PHP memory, database connections, or processing capacity can cause the server to fail mid-response. This is particularly common under sudden traffic spikes or on resource-constrained hosting plans.
Corrupted or invalid .htaccess file
On Apache-based servers, a misconfigured .htaccess file can cause the server to behave unexpectedly. Even a single erroneous character can prevent requests from being processed correctly.
Server firewall blocking Cloudflare
A server-side firewall or security tool may be blocking requests from Cloudflare’s IP ranges. If the server doesn’t recognise Cloudflare as a trusted source, it may respond abnormally or not at all.
SSL/TLS configuration mismatch
A mismatch between the SSL mode set in Cloudflare and the actual SSL certificate configuration on your origin server can result in an invalid or refused response.
How do I diagnose a 520 error?
Step 1 — Check your server error logs
Your hosting control panel (cPanel, Plesk, or similar) will give you access to your server’s PHP and Apache/Nginx error logs. These often identify the exact cause — a memory limit exceeded, a fatal PHP error, or a specific file causing problems.
Step 2 — Test your origin server directly
Try accessing your website using its origin server IP address rather than the domain name. This bypasses Cloudflare entirely. If the site loads correctly this way, the issue lies in how your server is responding to Cloudflare specifically, rather than a general outage.
Step 3 — Review the Cloudflare dashboard
Log in to your Cloudflare account and check the Analytics and Error Analytics sections. Cloudflare will often provide additional context about the type of invalid response it received and when errors began occurring.
Step 4 — Identify recent changes
Consider what changed around the time the errors started. A plugin update, a new deployment, a scheduled task, or a configuration change are all common triggers. Reversing or reviewing recent changes is one of the quickest ways to narrow down the cause.
How do I fix a 520 error?
Fix 1 — Resolve PHP or application errors
If a PHP fatal error is causing an empty response, enable WP_DEBUG in your wp-config.php on a staging or development environment to surface the error message. On a live site, review your error logs instead. Deactivating recently updated or added plugins one by one is a reliable way to identify a problem plugin.
Fix 2 — Increase server resource limits
If PHP memory limits are being exceeded, increase the memory allocation in your php.ini file or by adding define('WP_MEMORY_LIMIT', '256M'); to your wp-config.php. Your hosting provider can assist if you’re unsure of the appropriate limit for your plan.
Fix 3 — Replace or regenerate your .htaccess file
If you suspect a corrupted .htaccess file, replace it with a clean default version. In WordPress, you can regenerate a fresh .htaccess file by navigating to Settings > Permalinks in your dashboard and clicking Save Changes — no other changes are required.
Fix 4 — Whitelist Cloudflare IP addresses
If your server-side firewall is blocking Cloudflare’s requests, add Cloudflare’s IP ranges to your server’s allowlist. Cloudflare publishes its full, up-to-date list of IP addresses at cloudflare.com/ips. Your hosting provider or server administrator can add these to your firewall rules.
Fix 5 — Correct your SSL/TLS configuration
In your Cloudflare dashboard, navigate to SSL/TLS > Overview and check which mode is selected. Ensure it matches your server’s actual certificate setup:
- Flexible — No SSL certificate on your origin server
- Full — SSL certificate present but may be self-signed
- Full (Strict) — Valid, trusted SSL certificate installed on the origin server
A mismatch here — for example, Full (Strict) selected but no valid certificate on the server — is a common and easily overlooked cause of 520 errors.
Fix 6 — Temporarily disable Cloudflare (Development Mode)
As a diagnostic step, you can enable Development Mode in the Cloudflare dashboard under Caching > Configuration. This temporarily bypasses Cloudflare’s cache and some processing. If errors cease in Development Mode, it helps confirm that the issue is related to how Cloudflare is interacting with your server, rather than the server itself being broken.
What if the error keeps coming back intermittently?
Intermittent 520 errors are often a sign of a server under resource pressure — the error occurs during periods of high load or when certain resource-intensive processes (such as a scheduled backup or a WooCommerce import) are running. In this case, reviewing your hosting plan’s resource limits, optimising database queries, or upgrading your hosting environment may be necessary for a permanent resolution.
Do I need to contact my hosting provider or a developer?
If you’ve worked through the steps above without success, or if you don’t have access to server error logs and configuration files, then yes — this is the point to bring in professional support. A 520 error rooted in server configuration, firewall rules, or application-level PHP issues will require access to the server environment to resolve properly.
If your website is hosted or supported by O’Brien Media, please get in touch with our support team and we’ll investigate on your behalf. You can reach us on 01793 239239, by email at [email protected], or via the Help & Support section of your Client Connect portal.
Quick reference summary
| Possible Cause | Where to Check | Fix |
|---|---|---|
| PHP fatal error | Server error logs / WP_DEBUG | Identify and resolve the error; deactivate problem plugins |
| Empty server response | Server error logs | Investigate crashed scripts or processes |
| Memory limit exceeded | Server error logs / php.ini | Increase PHP memory limit |
| Corrupted .htaccess | File Manager / FTP | Replace with clean default; regenerate via Permalinks |
| Cloudflare IPs blocked | Server firewall / hosting panel | Whitelist Cloudflare IP ranges from cloudflare.com/ips |
| SSL/TLS mismatch | Cloudflare dashboard > SSL/TLS | Align Cloudflare SSL mode with origin server certificate |
| Server resource exhaustion | Hosting control panel / logs | Optimise resource usage or upgrade hosting plan |
