Skip to content

Conversation

@dev-hari-prasad
Copy link

When using the Environment API, setting server.hmr: false should fully disable the HMR pipeline, including preventing the WebSocket server from starting. However, Vite only checked server.ws === false, which caused the WS server to initialize even when HMR was disabled.

This resulted in EADDRINUSE errors in monorepos and SSR environments that run multiple Vite instances in parallel (e.g., Nuxt).

This change updates createWebSocketServer() to treat server.hmr: false as a hard disable for the WebSocket server, matching expected behavior and ensuring no WS port is opened when HMR is turned off.

Fixes #21041.

…s#21041)

When using the Environment API, setting `server.hmr: false` should fully
disable the HMR pipeline, including preventing the WebSocket server from
starting. However, Vite only checked `server.ws === false`, which caused
the WS server to initialize even when HMR was disabled.

This resulted in `EADDRINUSE` errors in monorepos and SSR environments
that run multiple Vite instances in parallel (e.g., Nuxt).

This change updates `createWebSocketServer()` to treat `server.hmr: false`
as a hard disable for the WebSocket server, matching expected behavior and
ensuring no WS port is opened when HMR is turned off.

Fixes vitejs#21041.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Environment API with server.hmr: false still creates WebSocket server causing port conflicts

1 participant