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

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

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

Exact message you may see tls: first record does not look like a TLS handshakehttp: TLS handshake error from: tls: first record does not look like a TLS handshakeClient sent an HTTP request to an HTTPS server.tls: oversized record received
Seen on: Go SSL

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?

🔧 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):

4-way handshake timeout / Incorrect password — Networking: wlan0: WPA: 4-way handshake failed - pre-shared key may be incorrect / WRONG_KEY (Networking)4-way handshake timeo…425 — HTTP 425 Too Early (HTTP)425525 — Cloudflare Error 525: SSL Handshake Failed (Cloudflare)525526 — Cloudflare Error 526: Invalid SSL Certificate (Cloudflare)526530 — 530 5.7.0 Must issue a STARTTLS command first (TLS required before AUTH or sending) (Email / SMTP)530530 5.7.0 Authentication Required — SMTP: 530 5.7.0 Must issue a STARTTLS command first / 530 5.7.1 Authentication required (Email / SMTP)530 5.7.0 Authenticat…A TLS error caused the secure connection to fail — Safari: Safari Can’t Open the Page — A TLS error caused the secure connection to fail (Browser)A TLS error caused th…assignment mismatch: 1 variable but f returns 2 values — Go: assignment mismatch: 1 variable but os.Open returns 2 values (Go)assignment mismatch: …Go TLS

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.