Nginx: [emerg] SSL_CTX_use_PrivateKey_file("/etc/ssl/server.key") failed (SSL: error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch)
The private key does not belong to the certificate configured in the server.
key values mismatchSSL_CTX_use_PrivateKey_file failed (SSL: error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch)X509_check_private_key:key values mismatchSSL: error:140A1175:SSL routines:SSL_CTX_use_PrivateKey:... key values mismatchprivate key does not match the certificate Meaning
Compare the public-key modulus of cert and key: they must be identical. Typical causes are pairing a new certificate with an old key, mixing keys from different CSRs, or pointing ssl_certificate at the wrong file. Reissue or use the key that generated the CSR.
Common causes
- Certificate renewed but old private key used
- Wrong files referenced (staging vs production)
- Key generated for a different CSR
- Certificate chain file used instead of leaf first
- Multiple domains' files mixed
⚡ Quick fix
- Compare hashes:
openssl x509 -noout -modulus -in cert.pem | md5sumandopenssl rsa -noout -modulus -in key.pem | md5sum - Use the key that matches the certificate
- Regenerate CSR and certificate if the key is lost
Detailed fix by platform
Linux
- For EC keys compare:
openssl x509 -noout -pubkey -in cert.pem | md5sum; openssl pkey -pubout -in key.pem | md5sum
How to diagnose
- Hashes — Equal?
- Files — Right paths?
- Order — Leaf first in the cert file?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- bind() failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
- ca md too weak / ee key too small OpenSSL: error:0A00018E:SSL routines::ca md too weak / error:140AB18F:SSL routines:SSL_CTX_use_certificate:ee key too small
- Could not automatically find a matching server block Certbot: Could not automatically find a matching server block for example.com. Set the `server_name` directive to use the Nginx installer
Most viewed in SSL / TLS
- NET::ERR_CERT_COMMON_NAME_INVALID NET::ERR_CERT_COMMON_NAME_INVALID: Your connection is not private (certificate is for a different domain)
- Challenge failed for domain Let’s Encrypt / Certbot: Challenge failed for domain example.com — Invalid response from http://example.com/.well-known/acme-challenge/x: 404
- no start line OpenSSL: unable to load certificate / PEM routines:get_name:no start line (key values mismatch)
Other ways to find it
Where this error sits
Origin: Network. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 4 Nov 2026