nginx.ccWeb server troubleshooting desk
Home / Errors / SSL
SSL

Nginx SSL handshake failed: troubleshooting

Short answer

SSL handshake failures usually come from a cert without the full chain, a cert/key mismatch, port 443 without the ssl parameter, too old/new protocols or ciphers, or SNI mismatch from a CDN.

Most common cause: ssl_certificate points to cert.pem instead of fullchain.pem; some clients miss the intermediate.

Try this first: Standard HTTPS block

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    http2 on;
    server_name example.com;
    ssl_certificate     /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_session_cache shared:SSL:10m;
}

Last verified: · against the official docs listed below · Sources

Typical log lines

SSL_do_handshake() failed (SSL: error:0A00010B:SSL routines::wrong version number)
SSL_CTX_use_PrivateKey("/etc/ssl/private/key.pem") failed (SSL: error:05800074:x509 certificate routines::key values mismatch)
peer closed connection in SSL handshake while SSL handshaking to upstream

Common causes

  1. ssl_certificate points to cert.pem instead of fullchain.pem; some clients miss the intermediate.
  2. Certificate and key do not match (only one was replaced on renewal).
  3. listen 443 lacks ssl, so nginx speaks plain HTTP on 443 (wrong version number).
  4. Only TLSv1.3 enabled, so old clients fail; or obsolete TLSv1.0 left on.
  5. Proxying to an HTTPS upstream without proxy_ssl_server_name, so SNI-based upstreams fail.

Diagnosis commands

Inspect chain and negotiation
#openssl s_client -connect example.com:443 -servername example.com </dev/null | head -20
Hashes must match (RSA keys)
#openssl x509 -noout -modulus -in fullchain.pem | md5sum; openssl rsa -noout -modulus -in privkey.pem | md5sum
Validity dates
#openssl x509 -noout -dates -in /etc/letsencrypt/live/example.com/fullchain.pem

Fix configs

Standard HTTPS block

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    http2 on;
    server_name example.com;
    ssl_certificate     /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_session_cache shared:SSL:10m;
}

Proxy to an HTTPS upstream

location / {
    proxy_pass https://upstream.example.net;
    proxy_ssl_server_name on;
    proxy_ssl_name upstream.example.net;
    proxy_set_header Host upstream.example.net;
}

Run nginx -t first, then systemctl reload nginx.

Key facts and sources

  • ssl_certificate should point at the full chain file, server certificate first, then intermediates. [nginx.org]
  • Since nginx 1.23.4 the ssl_protocols default is TLSv1.2 TLSv1.3. [nginx.org]

Checked against the linked pages on 2026-11-14; the official docs win if a newer nginx changes them.

FAQ

Browsers work but curl or an app fails?

Usually a missing intermediate. Browsers fetch it themselves; curl and many apps do not. Use fullchain.pem.

Where can I see the certificate expiry?

Run openssl x509 -noout -dates, or check online at ssl.sh. nginx.cc/fix also flags certs expiring within 14 days.

Fix it with a tool

Related errors

Sponsored slot (empty)
VPS / CDN recommendations may appear here later, labelled as affiliate links. There are no referral links today.