On this page
Cloudflare 525 and 526: How to Fix an SSL Handshake Failure
525 means Cloudflare could not complete a TLS handshake with your origin; 526 means the origin's certificate was rejected. How to tell them apart and fix each.
Quick answer
- Error 525 means the TLS handshake between Cloudflare and your origin server failed. The origin either is not listening on 443 with a valid certificate, or cannot negotiate TLS with Cloudflare.
- Error 526 means the handshake succeeded in reaching a certificate but the certificate was rejected — wrong hostname, self-signed, or expired.
- The difference matters: 525 is usually a missing or misconfigured origin listener, 526 is a certificate problem.
- Fixes are to set SSL/TLS mode to Full (strict), install a valid certificate for the hostname on the origin, and make sure the origin serves HTTPS on 443.
- Test the origin directly with the hostname Cloudflare sends, so you reproduce the same SNI and certificate validation.
What do Cloudflare 525 and 526 mean?
Both are errors from the connection between Cloudflare’s edge and your origin server — the visitor reached the edge, and the edge could not establish a secure connection onward. Error 525 means the TLS handshake failed. That is the earlier stage: the edge tried to negotiate encryption with the origin and did not get a usable response, which normally means nothing is listening correctly on the HTTPS port, the origin is refusing connections, or the two sides cannot agree on a protocol or cipher.
Error 526 is more specific: the handshake produced a certificate and the edge rejected it. That happens when the certificate does not cover the hostname being requested, is self-signed or otherwise untrusted, or has expired. So the pair forms a useful diagnostic order — 526 tells you a certificate exists but is wrong; 525 tells you a certificate was not successfully presented at all.
Step 1 — confirm which error and which mode
Check the SSL/TLS encryption mode for the zone. In Flexible mode, Cloudflare talks to the origin over plain HTTP while serving HTTPS to visitors; that is incompatible with an origin that expects HTTPS and a common source of confusion, including redirect loops. In Full mode, Cloudflare accepts any origin certificate, including self-signed, so a bad certificate may not produce 526 but provides no security. Full (strict) requires a valid certificate and is the correct setting for a real deployment.
If you see 525 and the mode is Full or Full (strict), the origin is not presenting TLS correctly. If you see 526, it is presenting something the edge will not accept. If you see redirect loops rather than either error, that is the Flexible mode mismatch described in the reverse-proxy and TLS guides.
Step 2 — test the origin the way Cloudflare sees it
From a machine outside Cloudflare, request the origin’s IP with the real hostname so the certificate is validated the same way. Set the server name explicitly, because a bare IP request will not exercise the certificate for the hostname and can produce a different result than the edge sees. Then inspect what the certificate actually covers.
The commands below separate the three cases: nothing listening, listening with a certificate, and the certificate’s hostnames. A connection refused means nothing is on 443; a successful handshake means TLS works and points at 526; a hostname mismatch in the certificate output explains a 526 immediately.
# 1. Is anything listening on 443 at the origin?
curl -v --resolve example.com:443:203.0.113.10 https://example.com/ 2>&1 | tail -20
# 2. What certificate does the origin present, and does it cover the hostname?
echo | openssl s_client -connect 203.0.113.10:443 -servername example.com 2>/dev/null \
| openssl x509 -noout -subject -issuer -dates -ext subjectAltName
# 3. Is the origin reachable on 443 at all (firewall / security group)?
nc -vz 203.0.113.10 443
# 4. Does the chain validate without -k, using the real hostname?
curl -v --resolve example.com:443:203.0.113.10 https://example.com/Step 3 — fix the cause
For a 525, make the origin serve TLS. That means a web server configured to listen on 443 with a certificate installed and the correct server name, a firewall or security group allowing Cloudflare’s address ranges, and support for a modern protocol version. If the origin is a proxy that terminates TLS, confirm it is actually the process answering on 443 rather than a default listener. Also check whether the origin only permits specific client IPs — if you restricted access to your own address, Cloudflare’s edges are blocked.
For a 526, install a certificate that is valid for the hostname. The usual route is a certificate issuance tool on the origin, tied to the same hostname record the zone uses, with automatic renewal. If the certificate is for www but the request is for the apex, or vice versa, that is the mismatch. Confirm the chain is complete, and that intermediate certificates are served, because an incomplete chain can be accepted by browsers that cache intermediates but rejected by a strict client.
Step 4 — verify from the edge, not the origin
After changing anything, confirm through Cloudflare rather than directly at the origin: request the hostname normally and expect a successful response, not an error page. Then confirm the origin still refuses plain HTTP where it should, so the fix did not open an unencrypted path. Finally, set the certificate to renew automatically and add a monitor for its expiry, because a certificate that lapses produces exactly the same 526 later.
Keep the cause in the runbook. Both errors have a small number of causes, and the two commands in the previous step identify which one in under a minute the next time. The failure mode to avoid is changing several settings at once — mode, certificate, firewall — and losing the ability to tell which one was actually wrong.
Where this bites vibecoders
A generated deployment often assumes TLS is terminated somewhere upstream and configures the origin to serve plain HTTP on port 80, which is fine until the proxy expects HTTPS. The result is a 525 on every request, and the application logs show nothing because the request never arrives. The check is to ask, for every hop in the chain, what protocol it speaks and who holds the certificate — an assistant will implement the hop but rarely describe the chain.
Where AI coding assistants get this wrong
- Leaving SSL/TLS mode on Flexible while the origin expects HTTPS, producing loops or errors.
- Issuing a certificate for the wrong hostname, such as
wwwwhen traffic goes to the apex. - Restricting origin access to specific IPs and blocking the CDN’s edge addresses.
- Serving an incomplete certificate chain, which some clients accept and strict ones reject.
- Changing mode, certificate, and firewall at once, obscuring which fix worked.
- Assuming the application logs will show the failure when the request never reaches it.
Checklist
- Identify whether the error is 525 (no handshake) or 526 (certificate rejected).
- Set SSL/TLS mode to Full (strict) for a real deployment.
- Confirm the origin listens on 443 with TLS and the correct server name.
- Check the certificate’s hostnames, issuer, and expiry.
- Allow the CDN’s address ranges through the origin firewall.
- Verify through the CDN after every change, and monitor certificate expiry.
FAQ
What is the difference between Cloudflare 525 and 526?
525 means the TLS handshake to the origin failed, usually because nothing is correctly listening on 443. 526 means a certificate was presented but rejected, typically because it does not cover the hostname, is self-signed, or has expired. Diagnosing which one you have tells you whether to fix the listener or the certificate.
Why do I get 525 with Full (strict) enabled?
Because in strict mode the origin must present a certificate the edge trusts for that hostname. If the origin only serves HTTP, if its TLS listener is misconfigured, or if its certificate is missing or untrusted, the handshake fails. Set up a valid certificate on the origin first, then enable strict mode.
Can a firewall cause a 525?
Yes. If the origin restricts port 443 to a known set of addresses, the CDN’s edge nodes will be refused and the handshake will fail. Allow the provider’s published address ranges, or its authenticated origin-pull certificate, and confirm with a connection test to port 443 from outside your network.
How do I avoid this recurring?
Use automated certificate issuance and renewal on the origin, keep the certificate’s hostnames aligned with the DNS records, and monitor expiry separately from uptime. Most repeats of these errors are an expired certificate or a hostname mismatch introduced by adding a record later, both of which monitoring catches before users do.
Related topics
- What Is a 502 Bad Gateway (and How Do You Fix It)?
- What Is a 504 Gateway Timeout (and How Do You Fix It)?
- What Is a Reverse Proxy?
- How to Serve Users in China Without an ICP Filing
- Don’t Let Your Domain Expire: Monitoring Domain and Certificate Renewals
- What Is DNS?