hostname SSL / TLS Origin: Network OSI layer 6 · Presentation Last updated 18 Nov 2026

Java: SSLPeerUnverifiedException — Certificate for <host> doesn't match any of the subject alternative names

The TLS handshake worked, but Java's hostname verification found the certificate isn't valid for the requested host.

Exact message you may see SSLPeerUnverifiedException: Certificate for <host> doesn't match any of the subject alternative namesjavax.net.ssl.SSLPeerUnverifiedException: Hostname not verifiedCertificate for doesn't match common name of the certificate subjecthostname in certificate didn't matchjava hostname verification failed
Seen on: Java SSL

Meaning

Connect using a name in the certificate's SAN (not an IP or alias), reissue the certificate with the right SANs, or fix the URL. Don't disable hostname verification in production (NoopHostnameVerifier).

Common causes

  • Connecting by IP/alias not in the SAN
  • Wrong or default certificate served
  • Wildcard doesn't match deeper subdomain
  • CN-only certificate
  • Load balancer certificate mismatch

⚡ Quick fix

  1. Use the hostname from the certificate
  2. Reissue with correct SANs
  3. Check what's served: openssl s_client -servername host

Detailed fix by platform

Shell

  1. openssl s_client -connect host:443 -servername host </dev/null | openssl x509 -noout -ext subjectAltName

How to diagnose

  1. Host — In SAN?
  2. Connection — By IP?
  3. Cert — Right one?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Network. Errors that are often confused with or caused by this one (click to open):

AH01909: server certificate does NOT include an ID which matches the server name — Apache: [ssl:warn] AH01909: example.com:443:0 server certificate does NOT include an ID which matches the server name (SSL / TLS)AH01909: server certi…apex — Wildcard certificate *.example.com doesn't cover example.com (the bare domain) (SSL / TLS)apexcipher suites — Java: SSLHandshakeException — no cipher suites in common (server side) (SSL / TLS)cipher suitesdisabledAlgorithms — Java: SSLHandshakeException — TLSv1/TLSv1.1 or algorithm disabled by jdk.tls.disabledAlgorithms (SSL / TLS)disabledAlgorithmsDjango — Django send_mail: ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] (EMAIL_USE_SSL vs EMAIL_USE_TLS on the wrong port) (Email / SMTP)Djangoerror 62 — openssl verify error:num=62:Hostname mismatch / Verify return code: 62 (SSL / TLS)error 62HELO — 504 5.5.2 Helo command rejected: need fully-qualified hostname (invalid EHLO name) (Email / SMTP)HELOJavaMail — javax.mail.MessagingException: Could not connect to SMTP host: smtp.example.com, port: 587 (JavaMail) (Email / SMTP)JavaMailhostname

Explore the map of this error Full error map →

🧠 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.