WebSocket connection to 'wss://x' failed
The browser couldn’t open (or keep) a WebSocket connection.
WebSocket connection toWebSocket is closed before the connection is establishedfailed: Error during WebSocket handshake Meaning
Proxies that don’t forward the Upgrade header, ws:// from an HTTPS page, wrong paths, and load balancer idle timeouts are typical.
Common causes
- Reverse proxy not forwarding Upgrade/Connection headers
- ws:// used on an HTTPS page (must be wss://)
- Wrong URL/path or server down
- Idle timeout closing the connection
⚡ Quick fix
- Configure proxy upgrade headers
- Use wss:// on HTTPS pages
- Send ping/heartbeats
- Check the server logs for the handshake
Detailed fix by platform
Nginx
- nginx
proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade";
How to diagnose
- Handshake — Status of the upgrade request (101 expected)?
- Proxy — Upgrade headers forwarded?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in JavaScript
- TypeError TypeError: Cannot read properties of undefined (reading 'x')
- QuotaExceededError QuotaExceededError: Failed to execute 'setItem' on 'Storage': Setting the value exceeded the quota
- module MIME type Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html"
Other ways to find it
Where this error sits
Origin: On your device. Errors that are often confused with or caused by this one (click to open):
🧠 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.
Report a correction or suggest an improvement
Last updated 9 Oct 2026