On this page
An HTTPS rollout can expose WebSocket connections that still use ws://. A secure page may block those connections as mixed content, leaving live updates, notifications, or other features disconnected. To find insecure ws connections before an HTTPS migration, reproduce each real-time feature on the HTTPS site and inspect the connection attempt—not just the page load.
This guide covers how to find the request in browser DevTools, change the endpoint safely, and distinguish a scheme problem from a server-side handshake failure.
Key Takeaways
- Use
wss://for WebSockets opened by an HTTPS page. Confirm that the endpoint actually supports TLS and WebSocket traffic before changing its URL. - In DevTools, inspect both the Console and Network panel. A browser-blocked connection may not produce a visible network request.
- A
wss://URL does not guarantee a successful handshake: certificates, proxies, paths, authentication, and backend configuration can still cause failures. - Browser behavior and documentation could not be verified for this article. Check the current WHATWG URL Standard, MDN WebSocket and mixed-content documentation, and your supported browsers before release.
Why an HTTPS page can fail with ws://
ws:// identifies an unencrypted WebSocket connection; wss:// identifies a WebSocket connection protected by TLS. Their relationship is similar to that of HTTP and HTTPS. WebSockets begin with an HTTP-based handshake, after which the connection carries WebSocket messages.
A page loaded securely can be undermined if it communicates over an unencrypted connection. Browsers may therefore block an insecure WebSocket opened from an HTTPS page as mixed content. Exact diagnostics and behavior can vary by browser and version, so reproduce the issue in the browsers you support.
Changing ws:// to wss:// is necessary for a secure-page connection, but it is not sufficient. The destination must accept TLS and route the handshake to a WebSocket-capable service. A third-party endpoint may need a separately documented secure URL.
Advertisement
Find the failing WebSocket connection in DevTools
Use a staging environment that matches the intended HTTPS deployment, including its proxy and authentication configuration. The panel names and controls below may vary between browsers.
- Open the HTTPS page, then open Developer Tools. Select the Network panel and enable Preserve log, if available.
- Select the WS or WebSocket filter. Reload the page, then perform the action that starts the connection—for example, opening a live dashboard. Some applications connect only after login or a user action.
- Select the WebSocket request. In its headers or details, inspect the Request URL: scheme, hostname, port, path, and query string. An HTTPS page attempting
ws://is the issue to investigate. - Inspect the status and any available response headers. A successful HTTP/1.1 WebSocket upgrade normally uses status
101; do not assume every WebSocket connection uses the same underlying HTTP version or DevTools display. - If no request appears, check the Console for mixed-content, WebSocket, or certificate errors. A browser can reject an attempt before it appears as a normal network request. Also confirm the feature was triggered and temporarily clear filters that might hide it.
- After making a fix, reload and repeat the feature workflow. Confirm that the connection remains open as expected and that messages flow in both directions where the feature requires them.
Do not paste production request URLs containing tokens or personal data into tickets or public tools. Record a redacted host and path instead.
Search the application as well
A DevTools session only reveals paths you exercise. Search frontend source, environment configuration, generated bundles, and relevant server-rendered templates for ws:// and WebSocket construction. Check lazy-loaded features, workers, and code supplied by third parties. Configuration can be injected during deployment, so inspect the built application as well as source files.
Select the secure endpoint
For a WebSocket served at the same host and port as the page, derive the scheme from the page URL rather than hard-coding ws://. This browser-side example assumes the site is loaded over HTTP or HTTPS and that /socket is the intended WebSocket path:
if (location.protocol !== 'http:' && location.protocol !== 'https:') {
throw new Error('This page must be served over HTTP or HTTPS');
}
const endpoint = new URL('/socket', location.href);
endpoint.protocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
const socket = new WebSocket(endpoint.href);
socket.addEventListener('error', () => {
console.error('WebSocket connection failed; inspect DevTools for details');
});
socket.addEventListener('close', (event) => {
console.info('WebSocket closed', event.code);
});
The leading slash makes /socket relative to the origin, not the current page path. The URL retains a non-default page port. It does not establish that the server serves WebSockets at that path: configure and test the endpoint separately. This example has not been executed here.
If the WebSocket lives on a different host or port, use an explicit environment-specific endpoint instead. Verify its certificate, route, and access policy. Do not assume that replacing the scheme on an external ws:// URL makes a secure endpoint available. Avoid putting credentials or sensitive tokens in query strings, which can be logged or exposed in diagnostic tools.
Check the reverse proxy and handshake
A common deployment terminates TLS at a reverse proxy and forwards traffic to an application server. The browser connects using wss://; the proxy must then forward the handshake to the correct backend. Protect the proxy-to-backend connection appropriately for your network and threat model.
For an illustrative Nginx configuration, this location is for a WebSocket-only /socket endpoint. It assumes TLS and the surrounding server block are already configured and that the backend listens on the same machine. Review and test it against your Nginx version and deployment; it has not been executed or verified here.
location = /socket {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
}
The proxy forwards the HTTP/1.1 upgrade headers to the backend. Ensure that the backend actually accepts WebSockets at /socket, that proxy and load-balancer idle timeouts fit the application's heartbeat behavior, and that TLS certificates match the public hostname. If the backend trusts forwarded headers, restrict that trust to known proxies; clients must not be able to forge trusted metadata directly.
Advertisement
Diagnose the failure by layer
- Console reports mixed content and the URL is
ws://: fix the client endpoint and provide a working secure destination. - The URL is
wss://, but TLS fails: investigate the certificate, hostname, port, and TLS termination. An upgrade header cannot fix a failed TLS connection. - An HTTP response appears instead of a successful handshake: check the path, proxy routing and upgrade handling, authentication, and backend logs. A redirect or ordinary error page is not a functioning WebSocket connection.
- The handshake succeeds but the connection closes later: inspect application and proxy logs, close codes, heartbeat behavior, and idle timeouts. This is different from a browser blocking
ws://.
WebSocket endpoints still need authentication and authorization. Validate the Origin where appropriate for browser clients, especially when cookies authenticate the connection; do not treat Origin as a substitute for user authentication or authorization.
Common Mistakes
- Testing only the homepage: connections may start on other routes or after a user action.
- Checking only the Network panel: a blocked attempt can be visible in the Console without a normal request entry.
- Rewriting every external URL to
wss://: the provider must actually support that secure endpoint. - Treating every failure as mixed content: a valid
wss://request can fail during TLS, routing, authentication, or the handshake. - Assuming an HTTP/1.1
101is the only possible diagnostic: inspect the protocol and browser details for the connection being tested.
Best Practices
Test the release candidate over HTTPS through the same proxy and load-balancer path used in production. Exercise each feature that opens a socket, including authenticated and reconnect flows, and review browser diagnostics alongside backend and proxy logs. Keep endpoint configuration explicit for cross-origin services, and document who owns each external WebSocket dependency.
Conclusion
Find WebSocket attempts with DevTools and source searches, replace insecure endpoints with supported secure ones, then verify the complete TLS, proxy, and backend path. A successful HTTPS page load alone does not prove its real-time features are ready for release.
What would your domain sell for?
A free TidyURLs account unlocks the Domain Estimator. It prices a name from 191,011 real domain sales.