← Back to all articles

Cloudflare Error 525: SSL Handshake Failed

by Unknown Proxies

10 min read

Updated October 17, 2026

Cloudflare error 525 "SSL handshake failed" means Cloudflare reached your origin server but could not finish the TLS handshake with it. Visitors cannot fix it. Only the site owner can. It appears only in Full or Full (strict) mode, and the first fix is to confirm the origin answers on port 443 with a certificate for the hostname.

Cloudflare's error 525 documentation lists four causes:

Quick fix for site owners. Run this test against your origin IP. Replace 203.0.113.10 and example.com with your values:

openssl s_client -connect 203.0.113.10:443 -servername example.com </dev/null

If it fails, the output tells you which of the four causes you have. The next sections explain how to read it.

Visitors. Refresh once and wait. The failure is between Cloudflare and the website's server, so your browser, network, and IP are not involved.

Where error 525 happens

A request behind Cloudflare has two legs. The visitor connects to Cloudflare's edge, then Cloudflare opens its own connection to your origin. Error 525 is a failure on the second leg, which is why the browser can show a valid padlock for the Cloudflare edge certificate while the page still fails.

Your SSL/TLS encryption mode decides whether that second leg uses TLS at all. Cloudflare's encryption modes page (updated April 2026) defines them like this:

Mode Cloudflare to origin Can it return 525?
Off Plain HTTP No
Flexible Plain HTTP, even for HTTPS visitors No
Full HTTPS, certificate not validated Yes
Full (strict) HTTPS, certificate validated Yes, and 526 too
Strict (SSL-Only Origin Pull) Always HTTPS, certificate validated Yes, even for HTTP visitors

As of 2026 the default for new zones is Automatic SSL/TLS. It probes your origin over HTTP and HTTPS, picks the most secure mode the origin supports, and rolls back if origin connections start failing. If you set the mode by hand, you opted out of that check, so the mode stays where you left it even after the origin changes.

How to read the openssl s_client test

The command connects to the origin directly, sends the hostname with SNI, and prints the handshake result.

Output Likely cause Fix
Connection refused or connect:errno=111 Nothing listens on port 443 Enable HTTPS on the web server and open port 443
Connection hangs, then times out Firewall drops port 443 Allow Cloudflare IP ranges on port 443
Handshake error plus no peer certificate available The handshake failed before the server sent a certificate Confirm a certificate is configured for this hostname, then check TLS versions and ciphers
handshake failure or no shared cipher alert No common TLS version or cipher Enable TLS 1.2 or 1.3 and modern ECDHE cipher suites
Works with -servername, fails without it Normal for SNI-based hosting Nothing, Cloudflare sends SNI
Wrong certificate subject for your hostname SNI or virtual host misconfigured Fix the server block or virtual host for that hostname

You can also test a specific TLS version. Add -tls1_2 or -tls1_3 to the command. If both fail, the origin has no TLS version in common with Cloudflare.

A quick second check with curl skips certificate validation, which is what Full mode does:

curl -vk --resolve example.com:443:203.0.113.10 https://example.com/

If curl completes the handshake here but Cloudflare still shows 525, compare the origin's cipher list with the list on Cloudflare's origin cipher suites page. Also check whether a firewall or security tool treats Cloudflare IPs differently.

Test the origin, not the public hostname

Online SSL checkers and a plain curl https://example.com connect to Cloudflare's edge while the record is proxied. They report Cloudflare's certificate, which is fine, and tell you nothing about the origin. Always point the test at the origin IP with -connect or --resolve, as above.

How to fix error 525 as a website owner

Work through these in order. Most 525s end at step one or two.

1. Confirm port 443 is open

On the server:

sudo ss -tlnp | grep ':443'

No output means no process listens for HTTPS. Enable the HTTPS server block or virtual host, then reload the web server.

If you serve the site on a non-standard port, Cloudflare only proxies certain HTTPS ports by default: 443, 2053, 2083, 2087, 2096, and 8443 (per Cloudflare's network ports reference, updated April 2026). An Origin Rule with a destination port override also sends traffic to whatever port it names, so check that port too.

2. Allow Cloudflare's IP ranges through the firewall

A host firewall, a cloud security group, or a security plugin that rate-limits or blocks Cloudflare's addresses causes 525s that look random. Cloudflare publishes its ranges as plain text at https://www.cloudflare.com/ips-v4 and https://www.cloudflare.com/ips-v6. With ufw on Ubuntu:

for ip in $(curl -s https://www.cloudflare.com/ips-v4) $(curl -s https://www.cloudflare.com/ips-v6); do
  sudo ufw allow from "$ip" to any port 443 proto tcp
done

Re-run it when Cloudflare updates the lists. If the firewall drops packets instead of rejecting them, you may see error 522 rather than 525.

3. Install a valid certificate

If the origin has no certificate, Cloudflare's docs recommend a free Cloudflare Origin CA certificate. Cloudflare can issue them for up to 15 years. Browsers do not trust Origin CA certificates, but Cloudflare does, which is all you need while the record stays proxied.

A minimal Nginx server block for the origin looks like this:

server {
    listen 443 ssl;
    server_name example.com www.example.com;

    ssl_certificate     /etc/ssl/cloudflare/example.com.pem;
    ssl_certificate_key /etc/ssl/cloudflare/example.com.key;
    ssl_protocols       TLSv1.2 TLSv1.3;

    root /var/www/example.com;
}

Reload with sudo nginx -t && sudo systemctl reload nginx. Then repeat the openssl s_client test.

4. Check SNI and virtual hosts

Each hostname needs a server block or virtual host that serves its certificate. If one subdomain fails and others work, that hostname probably falls through to a default block without a certificate.

Origin Rules can change the hostname too. Cloudflare's Origin Rules docs say a Host header override also rewrites the SNI value to match. If you route shop.example.com to a backend with a Host override, that backend must have a certificate and server block for the new name.

5. Check cipher suites and TLS versions

Old configs that allow only legacy ciphers, or only TLS 1.0, can fail the handshake. Nginx has defaulted to ssl_protocols TLSv1.2 TLSv1.3 since version 1.23.4, and its default ssl_ciphers HIGH:!aNULL:!MD5 overlaps with Cloudflare's list. If your config overrides either directive, compare it with the Cloudflare cipher list or use a current Mozilla "intermediate" profile.

6. Read the TLS errors in your logs

Cloudflare suggests you look at the origin error logs at the times the 525 occurred. Raise the log level if the errors do not show:

Nginx then logs lines such as SSL_do_handshake() failed with the OpenSSL reason, for example no shared cipher.

7. Check every upstream and Origin Analytics

Intermittent 525 errors often mean one server in a pool has a different certificate or TLS config. Run the openssl s_client test against each backend IP.

In the Cloudflare dashboard, the Origin status codes chart shows requests where Cloudflare got no HTTP response, recorded as an origin response status of 0. Those times usually match TLS failures in your logs.

Error 525 after a migration or DNS change

A lot of 525s start right after a host move. The old server had HTTPS set up, the new one does not yet, and the SSL/TLS mode still expects it.

To confirm the origin is the problem, set the record to DNS only (grey cloud) for a minute and load the site. A certificate warning or a refused connection points at the origin. Switch the proxy back on afterwards, because DNS only exposes your origin IP.

Error 525 vs. 526 and other origin errors

These errors are often confused.

Error What failed First check
525 The TLS handshake itself Port 443, certificate present, SNI, ciphers
526 Certificate validation in Full (strict) mode Expiry, trusted issuer, hostname match, chain
521 The origin refused the TCP connection Web server running, firewall allows Cloudflare
522 The TCP connection timed out Firewall drops, server overload

With 525, the connection fails before Cloudflare can use the certificate. With 526, the handshake works, but Cloudflare rejects the certificate in Full (strict) mode.

If Cloudflare connects and gets an empty or invalid HTTP response after the handshake, the error is 520 instead.

Is "handshake failed; returned -1" the same as error 525?

No. A log line such as ssl_client_socket_impl.cc handshake failed; returned -1, SSL error code 1, net_error -101 comes from Chromium. Chrome, Electron apps, Selenium with ChromeDriver, and Qt WebEngine can print it. It describes the client's own TLS connection, not the connection between Cloudflare and an origin.

The net_error number tells you more. For example, -100 is a closed connection, -101 is a reset connection, and -202 is a certificate from an untrusted authority. A TLS-inspecting proxy, an antivirus tool, or a server without a valid certificate often causes it. It is not a Cloudflare error code.

How to fix error 525 as a visitor

  1. Refresh once.
  2. Wait a few minutes.
  3. Send the site owner the URL and the time.

Browser settings do not fix a 525. Your browser's connection to Cloudflare works. The failure is behind Cloudflare.

Can proxies fix error 525?

No. The failed handshake is between Cloudflare and the origin. A different visitor IP does not change the origin's certificate, port, or ciphers.

If you scrape or monitor a site and see 525, treat it as an outage on the target. Rotating IPs or retrying fast does not repair a TLS config, so back off, log the time, and check again later. Our guide to crawling without getting blocked covers retry and backoff rules that keep a 525 from turning into a block once the site recovers.

How to prevent error 525

FAQ

What does Cloudflare error 525 mean?

It means Cloudflare could not complete the SSL/TLS handshake with the origin server. It only happens in Full, Full (strict), or Strict (SSL-Only Origin Pull) mode, and only the site owner can fix it.

Can I fix error 525 by switching to Flexible mode?

It usually removes the error, because Flexible mode connects to the origin over HTTP on port 80. It also removes encryption between Cloudflare and your server, and it causes a redirect loop if the origin forces HTTPS. Install a certificate on the origin instead.

Is error 525 the same as error 526?

No. Error 525 means the handshake failed. Error 526 means the handshake worked, but Cloudflare rejected the certificate in Full (strict) mode.

Do I need to buy a certificate for the origin server?

No. A free Cloudflare Origin CA certificate works for Full and Full (strict) mode while the record is proxied. A free public certificate, such as one from Let's Encrypt, also works and stays valid if you ever turn the proxy off.

Should I pause Cloudflare to fix error 525?

Pausing Cloudflare or setting the record to DNS only is a useful one-minute test, because it shows what the origin serves on its own. It is not a fix. It exposes your origin IP and removes Cloudflare's protection, so turn the proxy back on once you know the cause.

Why does error 525 happen only some of the time?

Intermittent 525s usually come from one backend in a pool with a different certificate or TLS config, a firewall that blocks some Cloudflare ranges, or an origin IP that changes. Test each backend IP directly and match the error times against your origin TLS logs.

Final thoughts

Error 525 is almost always an origin problem, and one openssl s_client run against the origin IP tells you which one. Fix the port, the certificate, or the firewall before touching Cloudflare's SSL mode. Dropping to Flexible hides the error and removes encryption on the second leg. After any host move, test the new origin's TLS before you flip DNS.

Need clean IPs for this setup?

Static ISP proxies for steady sessions and rotating residential pools when you need fresh exits, backed by a live site list and support on Discord.

View pricing