# Java: SSLException — Unrecognized SSL message, plaintext connection? (HTTPS client talking to an HTTP port)

**Code:** `plaintext` · **Category:** SSL / TLS · **Seen on:** Java, SSL

The client expects TLS, but the server answered with plain text, so the handshake can't start.

## 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

1. Use `http://` or enable TLS on the server port
2. SMTP: 465 = SSL, 587 = STARTTLS
3. Test the port with `curl -v`

## Detailed fix by platform

### Shell

1. 

```bash
curl -v http://host:8080/
openssl s_client -connect host:8080
```


## How to diagnose

1. **Port** — TLS or plain?
2. **Scheme** — Correct?
3. **STARTTLS** — Needed?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/ssl/java-unrecognized-ssl-message-plaintext-connection)
