Java: SSLException — Unrecognized SSL message, plaintext connection? (HTTPS client talking to an HTTP port)
The client expects TLS, but the server answered with plain text, so the handshake can't start.
Unrecognized SSL message, plaintext connection?javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?SSLException: Unsupported or unrecognized SSL messageplaintext connection? TLS Meaning
You are using https:// or SSL on a port that speaks plain HTTP/SMTP (e.g. 8080, 587 with STARTTLS instead of implicit TLS). Use the right port/scheme, or enable TLS on the server; for SMTP use STARTTLS on 587 and implicit TLS on 465.
Common causes
- https:// against an HTTP-only port
- Implicit SSL on a STARTTLS port (SMTP 587)
- Proxy returning a plain-text error
- Wrong protocol setting in the client
- Server not configured for TLS
⚡ Quick fix
- Use
http://or enable TLS on the server port - SMTP: 465 = SSL, 587 = STARTTLS
- Test the port with
curl -v
Detailed fix by platform
Shell
- bash
curl -v http://host:8080/ openssl s_client -connect host:8080
How to diagnose
- Port — TLS or plain?
- Scheme — Correct?
- STARTTLS — Needed?
🔧 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
- cipher suites Java: SSLHandshakeException — no cipher suites in common (server side)
- Django Django send_mail: ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] (EMAIL_USE_SSL vs EMAIL_USE_TLS on the wrong port)
- hostname Java: SSLPeerUnverifiedException — Certificate for <host> doesn't match any of the subject alternative names
Most viewed in SSL / TLS
- HTTPSConnectionPool: Max retries exceeded (SSLError) Python requests: HTTPSConnectionPool(host='api.example.com', port=443): Max retries exceeded with url: /v1 (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] ...')))
- DST Root CA X3 expired (old clients fail) Old clients: certificate has expired — Let's Encrypt chain uses expired DST Root CA X3 (OpenSSL 1.0.x, Android < 7.1.1)
- Keystore was tampered with, or password was incorrect Java keytool: java.io.IOException: Keystore was tampered with, or password was incorrect
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 18 Nov 2026