ByteTips.

Guide

Fix 'ERR_SSL_PROTOCOL_ERROR' in Localhost

Your browser tried HTTPS and the TLS handshake failed. On localhost that almost always means the server is speaking plain HTTP, an HSTS entry is forcing HTTPS, or a local certificate is untrusted.

October 24, 2026 · 5 min read · Shayan · JavaScript

Short answer: ERR_SSL_PROTOCOL_ERROR means the browser started a TLS handshake and the other side did not complete it. On localhost, the usual story is a mismatch: the URL says https:// but the dev server on that port is speaking plain HTTP, or a stale HSTS entry is forcing HTTPS onto a server that never had it. Work through the causes in order — most localhost cases are fixed in under a minute once you know which one you have.

Cause 1: the server is HTTP, the URL is HTTPS

This is the most common cause. Your dev server (Vite, Next.js, Express) defaults to plain HTTP, but you typed https://localhost:3000, or a bookmark or redirect sent you there. A plain-HTTP server cannot answer a TLS handshake, so Chrome reports ERR_SSL_PROTOCOL_ERROR. Fix: load http://localhost:3000 explicitly and check whether it works. If it does, the problem was never the server — it was the scheme.

Cause 2: a cached HSTS entry forces HTTPS

If you ever visited that localhost origin over HTTPS with a valid certificate, the browser may have cached an HSTS policy for it, and now every http:// request is silently upgraded to https:// before it leaves — straight into the same handshake failure. Fix: open chrome://net-internals/#hsts, scroll to 'Delete domain security policies', enter localhost (and the port-specific host if you use one, like myapp.localhost), and delete it. Then reload over http://. Firefox has the same concept under SiteSecurityServiceState in its profile data, but the Chrome path covers the majority of cases.

Cause 3: the local certificate is bad

If your dev server really does serve HTTPS (for example to test secure cookies or service workers), the certificate must be one the browser trusts, with a Subject Alternative Name matching the host. A self-signed certificate generated without a SAN for localhost, an expired certificate, or a certificate from an untrusted local CA all fail the handshake or the trust check. Fix: generate a trusted local certificate with mkcert — run mkcert -install once to trust its local CA, then mkcert localhost to create a certificate your browser accepts. Check the certificate's expiry if it worked before and stopped: local certificates commonly expire after a year or two.

Cause 4: something in the middle

  • A proxy, VPN, or antivirus web filter intercepting localhost traffic can break the handshake. Try with the proxy/VPN off and the filter paused to isolate it.
  • The wrong process on the port: another service listening on the same port answers the handshake with garbage. Check what is actually listening (lsof -i :3000 or netstat) and kill the squatter.
  • System clock far off: certificates have validity windows, and a clock set months wrong makes every certificate look expired or not-yet-valid. Fix the clock and retry.

What not to do

Do not train yourself to click through certificate warnings to reach a dev server and then carry that habit to real sites — a warning on a production domain means the connection may genuinely be intercepted. On localhost, fix the scheme, the HSTS entry, or the certificate instead; the warning is telling you something true.

Written by Shayan — Creator of Byte-Kit & ByteTips. Building private developer tools.

More JavaScript guides