There is no flag for this
$ zgrok http 3000
A WebSocket goes through the same tunnel as everything else. Point one at the port your socket server listens on and the upgrade goes through, on every plan.
What makes that work is that the decision is taken from your server's answer rather than from the request.
The upgrade goes through
101 Switching Protocols, the tunnel passes that response through untouched and gets out of the way of the bytes after it.Treated as a normal response
Nothing has to be configured for the first case, and nothing breaks in the second.
Connect with wss://, not ws://
This is the mistake to get out of the way first, because it fails in a way that looks like the tunnel is broken. The plain-HTTP endpoint answers a redirect rather than an upgrade:
HTTP/1.1 308 Permanent Redirect
Location: https://a1b2c3--acme-shop.zgrok.io/socketA browser's WebSocket handshake is specified to treat a redirect as an error rather than follow it, and most other clients behave the same way, so a ws:// URL fails without ever reaching your server. Use the wss:// scheme. If your client builds its URL from the page it is running on, derive the scheme instead of hardcoding it:
const scheme = location.protocol === "https:" ? "wss:" : "ws:";
const socket = new WebSocket(`${scheme}//${location.host}/socket`);When the handshake comes back as an ordinary response
If you get a status instead of an upgrade, your server declined it, and the status tells you which of two things happened.
An ordinary answer
200 means your server answered the request as an ordinary one. Usually that is the path: a socket server that only upgrades on /socket answers normally anywhere else. Vite adds a second version of the same thing, because it upgrades only connections that ask for its vite-hmr subprotocol and answers a plain 200 otherwise.The Host header
403 is the Host header. It is passed through unchanged, so your dev server sees the tunnel hostname rather than localhost, and a server that checks it against an allowlist refuses the request outright. Vite answers 403 Blocked request, naming the host and the config key to add, which reads like a tunnel fault and is produced entirely by Vite.What the inspector will not show you
Worth knowing before you go looking for it. The request inspector records requests and the responses to them, and an upgrade is neither: after the 101 the connection stops being a sequence of request and response pairs and becomes a stream of frames.
The handshake itself is visible, which is usually the part in question, because a realtime bug that turns out to be a tunnel problem is almost always a handshake that did not happen. Once the socket is open, your own client and server logs are the instruments. For the same reason, response headers you inject with --header are not applied to a 101: it is passed through as your server wrote it.
The address, if someone is coming back to it
On Free the assigned address is rewritten on your next run, which matters more here than elsewhere: a socket URL usually lives in a client config or an environment variable, and that value goes stale every session. A tunnel name you choose inside your project on Pro stays put across restarts:
$ zgrok http 3000 --subdomain myapp
If the connection drops, the CLI reconnects asking for the name it already has rather than a new one, so an ordinary blip does not move the URL your client is pointed at. It says so in the terminal on the one occasion it cannot, which is a tunnel deleted from the dashboard while the CLI was still holding its name.