Node.js & HTTPS / Vite

How to Fix "ERR_SSL_PROTOCOL_ERROR" on Localhost & Staging Web Servers (2026 Guide)

Step-by-step developer tutorial to diagnose and resolve ERR_SSL_PROTOCOL_ERROR in Chrome, Vite, Express, and Docker containers.

Arun Gupta
Written & technically audited by Arun Gupta, Principal Distributed Systems Architect
Verified on September 19, 2026 • Tested on Chrome 134, Safari 18.3 & Firefox 135
ADVERTISEMENT
⚠️ Browser Console Error & Runtime Stack Trace
❌ This site can’t provide a secure connection: localhost sent an invalid response (ERR_SSL_PROTOCOL_ERROR)
❌ Browser automatically redirects http://localhost:3000 to https://localhost:3000 due to HSTS preload or past session cache
❌ cURL error: error:1408F10B:SSL routines:ssl3_get_record:wrong version number

1. Root Cause Analysis (Engine-Level Breakdown)

When modern JavaScript engines (V8 in Chrome/Node.js, JavaScriptCore in Safari, and SpiderMonkey in Firefox) encounter this failure condition, execution halts or falls back to degraded behavior due to the following primary triggers:

In high-scale production systems, this error rarely occurs during local development because local environments lack network latency, third-party browser extensions, complex caching proxies, and production minification transforms that uncover timing race conditions.

2. Verified Production Solutions

The following code recipes provide immediate and architectural fixes for this error:

JAVASCRIPT
// 1. Vite HTTPS Local Development with mkcert:
// vite.config.js
import { defineConfig } from 'vite';
import basicSsl from '@vitejs/plugin-basic-ssl';

export default defineConfig({
  plugins: [basicSsl()],
  server: {
    https: true,
    port: 5173,
    host: 'localhost',
  },
});

// 2. Clear Chrome HSTS cache for localhost:
// Navigate to: chrome://net-internals/#hsts
// Under "Delete domain security policies", enter: localhost -> Click Delete.
ADVERTISEMENT

3. Step-by-Step Resolution Workflow

Follow this structured checklist to resolve and prevent this error in your CI/CD pipeline:

Step 1: Verify whether the server is listening on HTTP or HTTPS

Check your terminal console to confirm whether the local dev server is running on http:// or https://.

Step 2: Clear Chrome HSTS preload cache for localhost

Visit chrome://net-internals/#hsts and delete domain security policies for localhost.

Step 3: Use valid local CA certificates via mkcert

Install mkcert to generate trusted local SSL certificates rather than unvalidated self-signed certificates.

🔍 How ReMOAT Resolves This Error Where It Actually Happens

ReMOAT runs over encrypted WebRTC DataChannels, eliminating local SSL certificate errors and TLS negotiation failures entirely.

Inspect This Bug in ReMOAT DevTools →
ADVERTISEMENT