Home/Blog/How to Fix Cloudflare Error 520, 525, 526 (2026)

How to Fix Cloudflare Error 520, 525, 526 (2026)

Cloudflare 520 525 526 error fix guide 2026

Cloudflare’s 520, 525, and 526 errors all point to the same thing: a broken connection between Cloudflare and your origin server. This Cloudflare 520 525 526 error fix guide explains what each code means, how to tell them apart in seconds, and the exact steps to resolve them. If your site sits behind Cloudflare and visitors are seeing these errors, work through this guide methodically.

What Do Cloudflare Errors 520, 525, and 526 Mean?

  • Error 520: Web Server Returned an Unknown Error โ€” Cloudflare connected to your origin, but the origin returned an empty, unexpected, or malformed response. Often caused by the origin crashing, a PHP fatal error, or a firewall blocking Cloudflare’s IPs.
  • Error 525: SSL Handshake Failed โ€” Cloudflare could not complete the TLS/SSL handshake with your origin server. The handshake never finished: no certificate arrived, port 443 is not answering, or the two sides share no cipher suite.
  • Error 526: Invalid SSL Certificate โ€” the handshake completed, but the certificate your origin presented failed validation: expired, self-signed, revoked, hostname mismatch, or missing intermediate certificate. This error only appears under Full (Strict) SSL mode.

The key distinction: 525 means the handshake never completed; 526 means the certificate failed validation. A quick test โ€” temporarily switching Cloudflare’s SSL mode from Full (Strict) to Full โ€” separates them: if the error disappears, it was a 526 certificate problem; if it persists, it is a 525 handshake problem.

How to Fix Cloudflare Error 520

1. Check Your Origin Server Logs

Error 520 usually means your origin crashed or returned garbage. Check your PHP error log and web server error log for fatal errors or out-of-memory kills around the time the error appeared. Fix any crashing code or plugin first. Our 500 error fix guide covers the most common server-side crashes.

2. Whitelist Cloudflare IP Ranges

Firewalls (including fail2ban, CSF, and host firewalls) sometimes block Cloudflare’s edge IPs, causing resets that surface as 520. Whitelist Cloudflare’s published IP ranges in your firewall and server security tools.

3. Disable Cloudflare Proxying Temporarily (Grey Cloud)

In Cloudflare DNS settings, click the orange cloud to turn it grey (DNS-only) for the affected record. If the site loads fine directly, the problem is in the Cloudflare-to-origin path. If it still fails, the problem is purely on your origin.

How to Fix Cloudflare Error 525 (SSL Handshake Failed)

4. Verify Your Origin Has a Working Certificate on Port 443

Test your origin directly, bypassing Cloudflare: openssl s_client -connect YOUR_ORIGIN_IP:443 -servername example.com. If nothing answers on port 443, your web server is not listening for HTTPS โ€” install a certificate or open the port.

Fixing Cloudflare 520, 525 and 526 SSL errors step by step

5. Fix SNI and Virtual Host Mismatches

Cloudflare always sends SNI with your hostname. If your origin hosts multiple sites and has no virtual host matching that hostname, the request falls through to a default vhost with no usable certificate โ€” producing a 525. List your vhosts (apachectl -S or nginx -T) and add the missing one.

6. Check TLS Version and Cipher Compatibility

Your origin must support TLS 1.2 or 1.3 with cipher suites Cloudflare offers. An origin restricted to only legacy or only ultra-modern ciphers will fail to find common ground. Update your SSL configuration to a standard modern set.

How to Fix Cloudflare Error 526 (Invalid SSL Certificate)

7. Renew or Replace the Origin Certificate

Read the certificate Cloudflare sees: openssl s_client -connect ORIGIN_IP:443 -servername example.com -verify_hostname example.com. The verify return code names the problem: code 10 means expired, 18/19 means self-signed, 62 means hostname mismatch, 20/21 means missing intermediate. Renew expired certificates (Let’s Encrypt: certbot renew), install missing intermediates, or replace self-signed certs with a trusted CA certificate or a free Cloudflare Origin CA certificate.

8. Set the Correct Cloudflare SSL Mode

In Cloudflare dashboard > SSL/TLS, use Full (Strict) when your origin has a valid certificate โ€” this is the recommended, most secure setting. Use Full (not Strict) only temporarily while waiting for a new certificate to be issued. Never use Flexible โ€” it leaves the Cloudflare-to-origin connection unencrypted and commonly causes redirect loops. For redirect loop issues, see our ERR_TOO_MANY_REDIRECTS fix.

How to Prevent Cloudflare 520/525/526 Errors

  • Enable AutoSSL or certbot auto-renewal so origin certificates never expire silently.
  • Set up uptime monitoring that checks both the Cloudflare edge and the origin directly.
  • Keep Cloudflare IP ranges whitelisted after every firewall change.
  • After any server migration, verify the certificate chain and SNI vhosts before re-enabling the orange cloud.
  • Document your SSL mode choice so future changes do not accidentally downgrade it.

Conclusion

Cloudflare 520, 525, and 526 errors look cryptic, but each has a clear meaning: 520 is a bad origin response, 525 is a failed handshake, and 526 is a bad certificate. Diagnose with the openssl commands above, fix the specific cause โ€” usually an expired certificate, a missing vhost, or a blocked Cloudflare IP โ€” and keep SSL mode on Full (Strict) with a valid origin certificate. Your site will be back behind Cloudflare’s protection in no time. For more fixes, explore our free website tools.