WebSocket handshake failed with unexpected response code: 404 — why?

The WebSocket connection attempt received 404. Open the handshake request and check its final host and path. The frontend may be pointing to the wrong endpoint, or the proxy may send the request to a handler that never registered that route.
Compare the request with the deployed WebSocket route. For an HTTP/1.1 upgrade, check that the proxy forwards the required Upgrade and Connection headers and routes the request to the WebSocket handler. A regular web route on the same host can be working while the socket route is missing.
const ws = new WebSocket('wss://example.com/ws'); ws.addEventListener('error', error => console.error('WebSocket error', error));
Watch for the socket’s open event after correcting the route. If the path looks right but no upgrade reaches the backend, compare the public and internal route mappings for the WebSocket handler.
Inspect the failed handshake path in Network and match it to the WebSocket route in the proxy and backend logs.