# Go: tls: first record does not look like a TLS handshake (HTTP server spoken to with HTTPS)

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

A Go TLS client or server received plain HTTP bytes instead of a TLS handshake.

## Meaning

Either the client uses `https://` for a plain HTTP endpoint, or a browser/client sent HTTP to a Go `ListenAndServeTLS` port. Use the right scheme, serve TLS on the right port, or put a redirect listener on the plain port.

## Common causes

- HTTPS client to an HTTP-only port
- HTTP request to a TLS listener
- Proxy speaking HTTP to a TLS backend
- Mixed ports in config
- Wrong scheme in the URL

## Quick fix

1. Fix the URL scheme/port
2. Add a separate HTTP listener that redirects to HTTPS
3. Check `ListenAndServe` vs `ListenAndServeTLS`

## Detailed fix by platform

### Go

1. 

```bash
go http.ListenAndServe(":80", http.HandlerFunc(redirectToHTTPS))
http.ListenAndServeTLS(":443", "cert.pem", "key.pem", mux)
```


## How to diagnose

1. **Scheme** — Matches?
2. **Listener** — TLS or plain?
3. **Redirect** — Present?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/ssl/go-first-record-does-not-look-like-a-tls-handshake)
