VPS Tutorials
Fix Cloudflare 525 and 526 on a VPS: Origin TLS and Full (strict) (2026)
Identify the failing origin, test TLS with SNI, repair certificate chains and verify fresh Cloudflare traffic without weakening identity checks.

A Cloudflare-proxied site showing 525 SSL handshake failed or 526 Invalid SSL certificate usually needs attention on the HTTPS connection between Cloudflare and the VPS origin. A valid Cloudflare certificate in your browser does not establish that the origin certificate or TLS configuration is correct.
This guide covers ordinary proxied HTTPS sites, using a Linux VPS, Nginx, curl and OpenSSL. Identify the error, confirm the actual origin, test TLS with the correct hostname, repair the certificate or handshake settings, and verify a fresh request through Cloudflare. Tunnel, Spectrum and Zero Trust Gateway use different connection models; consult their product-specific troubleshooting documentation as well.
| Error | Where it fails | Start with |
|---|---|---|
525 SSL handshake failed | TLS handshake between Cloudflare and the origin | HTTPS listener, SNI, protocols/ciphers, resets and client-certificate requirements |
526 Invalid SSL certificate | Validation of the origin certificate | Dates, hostname, issuer, chain and the certificate actually returned |
For an ordinary proxied website, 525 can occur in Full or Full (strict) mode. A 526 usually concerns origin-certificate validation under Full (strict). Certificates can be involved in either error, but the investigation starts differently. See Cloudflare's 525 documentation and 526 documentation.
There are two connections: visitor → Cloudflare → VPS origin. The edge certificate protects the first; the origin certificate protects the second. Replacing an edge certificate may therefore leave the origin failure untouched.
Save the full hostname, time, error code and Ray ID. For intermittent failures, record successful periods too. In the Cloudflare dashboard, check:
- The SSL/TLS encryption mode and any rules overriding it for this hostname.
- Whether the configured DNS origin address still belongs to the current VPS.
- Multiple A/AAAA addresses, load-balancer origins and custom origin ports.
- Origin Rules changing the destination, Host header or SNI.
Public DNS normally returns Cloudflare addresses while proxying is enabled. An edge IP returned by dig example.com is not the VPS origin. Confirm the origin using the dashboard and instance details.
One expired certificate in a pool can make repeated refreshes appear to fix the problem. Check every address that can receive origin traffic, including IPv4 and IPv6, against the actual listeners.
Replace example.com with the failing hostname and 203.0.113.10 with the origin IP. curl's --resolve temporarily selects an address while retaining the hostname in the URL:
curl -v --connect-timeout 5 --max-time 15 --noproxy '*' \
--resolve example.com:443:203.0.113.10 \
https://example.com/ -o /dev/null
The request reaches that IP, while example.com still determines TLS SNI, certificate hostname verification and HTTP Host handling. --noproxy '*' prevents a local HTTP proxy from forwarding the test. This changes neither DNS nor the hosts file. See the curl manual.
Using only curl https://203.0.113.10, or adding only an HTTP Host header, may select the wrong TLS virtual host. Certificates generally identify domains: a mismatch during an IP-only request does not establish that Cloudflare sees the same failure.
| Direct-test result | Next check |
|---|---|
| Refused connection or timeout | Listener, port, firewall and whether this test source is allowed |
Handshake disconnect or wrong version number | Whether the endpoint really serves TLS and whether proxy/port mappings are correct |
| Expired certificate, hostname mismatch or chain failure | The certificate checks below; interpret Origin CA separately |
| Successful TLS verification followed by HTTP | This path works; investigate Cloudflare's origin path and rules |
An HTTP 403, 404 or application 500 is not a failed TLS handshake. Keep certificate validation, TLS establishment and the application response separate.
A blocked direct connection from your laptop may be intentional. Keep the restriction: test the actual listener locally on the VPS, or briefly allow a trusted management IP. A local test checks service configuration but does not prove Cloudflare's network path works.
Authenticated Origin Pulls (AOP) can require a client certificate. Ordinary curl without that certificate may correctly be rejected. Check Cloudflare's AOP settings, the origin's client CA and the logs before concluding HTTPS is broken. See the AOP explanation.
On the VPS, inspect listeners, validate configuration and read errors:
sudo ss -lntp
sudo nginx -t
sudo tail -n 100 /var/log/nginx/error.log
sudo journalctl -u nginx -b --no-pager -n 100
Use the port selected by the origin rules; it may differ from 443. For containers, ensure the public port reaches a TLS terminator rather than an HTTP-only application. With Caddy, Apache or another proxy, use that service's logs instead of running Nginx commands on a machine without Nginx.
Correlate logs with the failure time:
- Look for protocol, cipher or client-certificate errors around
SSL_do_handshake() failed. - Check resets specific to a source, hostname or listening address.
- Check unreadable or mismatched certificate/key files and configuration that never loaded.
- Confirm the HTTPS origin port has not been mapped to plain HTTP.
Inspect the TLS fields in Nginx's effective configuration:
sudo nginx -T 2>&1 | grep -E 'listen|server_name|ssl_certificate|ssl_protocols|ssl_ciphers|ssl_verify_client|ssl_client_certificate'
The intended HTTPS server block must match server_name. With multiple domains on one IP, SNI affects the certificate returned. Default sites, overlapping names and incorrect listeners can select another site's certificate. See Nginx HTTPS configuration.
Identify the specific incompatibility and use settings supported by your service version and Cloudflare. Enabling obsolete TLS, removing all cipher restrictions or disabling client-certificate authentication is not a durable repair.
Full (strict) requires an unexpired origin certificate issued by a trusted public CA or Cloudflare Origin CA, covering the requested or target hostname. See the Full (strict) requirements.
Inspect what the origin actually sends, with SNI:
timeout 15 openssl s_client \
-connect 203.0.113.10:443 \
-servername example.com -showcerts </dev/null
-showcerts displays the certificates sent by the server; it does not establish successful trust validation. For a normal public-CA certificate, also check hostname and trust:
timeout 15 openssl s_client \
-connect 203.0.113.10:443 -servername example.com \
-verify_hostname example.com -verify_return_error </dev/null
OpenSSL may otherwise report verification errors and continue the handshake. -verify_return_error stops on verification failure. See s_client options. Local trust and Cloudflare's assessment are not identical: interpret this alongside the certificate type, dashboard settings and actual proxied result.
For Certbot-managed certificates, inspect local details too:
sudo certbot certificates
sudo openssl x509 -in /etc/letsencrypt/live/example.com/cert.pem \
-noout -subject -issuer -dates -ext subjectAltName
Check these certificate details:
notBeforeandnotAftermust include the current time.- The SAN must cover the failing hostname:
*.example.comcovers neither the apexexample.comnora.b.example.com. - Exclude another site's certificate or an updated file with an old certificate still served.
- Check for missing or incorrect intermediate certificates.
A new file on disk does not prove the listener uses it. Compare local details with the served certificate across server blocks, origin nodes and container mounts.
For a typical Certbot layout, check these fields in the existing HTTPS server block:
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
These are field examples, not a replacement for the entire site configuration. For another CA, follow its chain instructions. Nginx expects the server certificate before the intermediates in a combined file; see SSL certificate chains. Keep unrelated certificates out of the chain, and keep the private key in a restricted origin file, never in public logs or screenshots.
A Cloudflare Origin CA certificate can satisfy Full (strict), but ordinary browsers and local curl generally do not trust it by default. After disabling proxying, pausing Cloudflare or accessing the origin directly, unknown CA or NET::ERR_CERT_AUTHORITY_INVALID may simply reflect that boundary. See Origin CA and its troubleshooting guidance.
To validate it from a trusted management machine, obtain the appropriate root certificate for its issuer type from Cloudflare's official documentation, verify the source, save it locally and explicitly use it:
curl -v --connect-timeout 5 --max-time 15 --noproxy '*' \
--cacert /path/to/cloudflare-origin-ca-root.pem \
--resolve example.com:443:203.0.113.10 \
https://example.com/ -o /dev/null
Replace the example CA path with the verified file. --cacert selects a public CA certificate for server trust; it is neither the site's private key nor the AOP client-authentication CA.
curl -k skips server-certificate verification, so success with it does not prove a 526 is fixed. If browsers must also access the origin directly, deploy a publicly trusted certificate for that entry point. A local warning alone is not a reason to change the whole site's encryption mode.
Record the original mode, rules, certificate paths and configuration. Back up the actual site file; this is only a common path example:
sudo cp -a /etc/nginx/sites-available/example.com \
/etc/nginx/sites-available/example.com.backup.$(date +%Y%m%d%H%M%S)
After repairing the chain, paths or TLS settings, validate before reloading:
sudo nginx -t && sudo systemctl reload nginx
If validation fails, repair or restore the configuration before restarting. Fix renewal through the renewal job and issuance process. Cloudflare documents switching from strict to Full as a temporary 526 workaround, but that weakens origin identity verification. Use it only as a short recovery decision with explicitly accepted risk; it does not repair the certificate.
The target is a correct origin completing TLS with a certificate acceptable to the chosen mode, plus working Cloudflare requests and application behavior. Flexible mode, disabling proxying or viewing an old cached page does not establish that outcome.
Retest every actual origin hostname, port and certificate, then request the public proxied hostname. Use a URL you have confirmed will not be served solely from old cache, and correlate the request time with origin logs. Check HTTP status and important login/API operations as well as the homepage.
For intermittent failures, compare certificates across all nodes, A/AAAA addresses and load-balancer pools. Retain the error time, Ray ID, failure logs and repair record; one successful node cannot establish that the whole pool works.
- Now seeing 521/522? Check origin listeners, firewall and connectivity.
- Renewal expired or not loaded? Use the Let's Encrypt, Certbot and DNS-01 guide.
- Configuration will not load? See Nginx validation and reload failures.
Locate the failing TLS connection, origin and served certificate before changing configuration. That gives you a repair you can verify while retaining origin identity checks.