Vite HMR through a tunnel: '[vite] failed to connect to websocket'
Vite 8.3.8, Chromium 159, macOS, 2026-11-15, dev server behind a local TLS reverse proxy standing in for a tunnel. With no server.hmr settings the client connects back to the page's own origin (wss://PUBLIC-HOST/?token=...) and logs [vite] connected., so a tunnel that forwards WebSocket upgrades needs only server.allowedHosts. If the proxy does not forward upgrades you see WebSocket connection to 'wss://PUBLIC-HOST/?token=...' failed, then a fallback attempt straight to the dev server address (wss://127.0.0.1:PORT, ERR_SSL_PROTOCOL_ERROR from an https page), then [vite] failed to connect to websocket. your current setup: (browser) HOST <--[HTTP]--> 127.0.0.1:PORT (server) ... <--[WebSocket (failing)]-->; the page still renders, only hot reload is dead. A leftover server.hmr.clientPort: 443 (old ngrok advice) breaks HMR when you open plain localhost: WebSocket connection to 'ws://127.0.0.1:443/?token=...' failed followed by [vite] failed to connect to websocket (Error: WebSocket closed without opened.) with no fallback, so remove it unless the public port really differs. Also verified: a proxy that rewrites Host to the local address (http-proxy changeOrigin: true) passed the host check and HMR with no allowedHosts entry at all.