Fix the HTTPS handshake between Cloudflare and your server

Cloudflare error 525 means Cloudflare tried to open an HTTPS connection to your origin server and the SSL handshake failed, so no request ever went through. It only happens when Cloudflare connects to your server over HTTPS, in its Full or Full (strict) encryption modes. The causes Cloudflare lists are a missing certificate, port 443 not open, no SNI support, no cipher suite the two sides share, or a key exchange the zone requires and the origin lacks.

Why the handshake fails

  • No valid certificate on the origin

    The server has no usable certificate for the hostname, so it can't finish the handshake. Full mode accepts a self-signed one, but there has to be one.

  • Port 443 isn't open

    Port 443, or the custom secure port the site uses, isn't open for TLS on the origin, so there's nothing to negotiate with.

  • No SNI support

    Cloudflare names the hostname it wants during the handshake. A server without SNI support can't match that name to the right site and certificate.

  • No cipher suite in common

    The suites your origin allows don't overlap with the ones Cloudflare offers, so the two sides can't agree on how to encrypt.

  • A key exchange the origin lacks

    If the zone requires post-quantum or FIPS key agreements, an origin that doesn't support the required algorithm fails the handshake.

Cloudflare's error 525 guide lists these causes and says the error needs both a failed handshake and the Full or Full (strict) mode. Its Full mode page asks for HTTPS on port 443 with a certificate that can be self-signed. Cloudflare lists the cipher suites it offers origins for each TLS version on its origin cipher suites page.

Test the handshake against your origin

# Handshake with the origin's IP (203.0.113.10 here), sending your hostname as SNI
openssl s_client -connect 203.0.113.10:443 -servername yoursite.com </dev/null 2>&1 \
  | grep -E 'Cipher is|:error:'

# Try TLS 1.2 and TLS 1.3 on their own to see which ones the origin accepts
openssl s_client -connect 203.0.113.10:443 -servername yoursite.com -tls1_2 </dev/null 2>&1 \
  | grep -E 'Cipher is|:error:'
openssl s_client -connect 203.0.113.10:443 -servername yoursite.com -tls1_3 </dev/null 2>&1 \
  | grep -E 'Cipher is|:error:'

Read the handshake result

  • A working handshake prints a Cipher is line naming the cipher the origin agreed to. The filter leaves out openssl's certificate checks, which don't matter for a 525, since Full mode doesn't check the certificate. If openssl prints Cipher is (NONE) and an error line, such as one with alert handshake failure or alert protocol version, you've reproduced the 525 without Cloudflare in the picture, and the server's error log for that moment should say why.

  • When 525s come and go, Cloudflare's guide suggests reading the server's SSL errors for those times. Apache records them once you turn on mod_ssl logging, and nginx writes them to its standard error log, though it may need a more detailed log level to show them.

How to fix Cloudflare error 525

  1. Install a certificate on the originGive the server a certificate covering every hostname Cloudflare connects to, from a public authority or from Cloudflare's Origin CA, and reload the web server.
  2. Open TLS on the right portMake the web server listen for HTTPS on 443, or the secure port your site uses, and allow that port through the host's firewall.
  3. Match the name Cloudflare sendsSet up an HTTPS site block or virtual host for your hostname, so the server picks its certificate from the SNI name in Cloudflare's handshake.
  4. Enable a shared cipher suiteCompare the TLS versions and cipher suites your server allows with the list Cloudflare documents for origin connections, and enable at least one they have in common.
  5. Support the required key exchangeTurn on a key exchange that meets the zone's post-quantum or FIPS requirement in the origin's TLS settings, or drop the requirement for the zone if your compliance rules allow it.

Frequently asked questions

What's the difference between error 525 and 526?

A 525 means the handshake itself failed, so no secure connection formed at all. A 526 means the connection could start but Cloudflare, in Full (strict) mode, couldn't validate the certificate your server sent. Cloudflare's guides for 525 and 526 list the causes of each.

Will switching to Flexible mode fix a 525?

It hides it. In Flexible mode Cloudflare reaches your server over plain HTTP, so there's no handshake to fail, but the traffic between Cloudflare and your server is no longer encrypted. Cloudflare's Flexible mode page says to use Full or Full (strict) instead for sites with logins or personal data. And if your server redirects HTTP to HTTPS, the same page warns that Flexible mode creates a redirect loop that makes the site unreachable. Fix HTTPS on the origin.