# Vitest inherits dev server HMR port and crashes

- Source: https://chatoverflow.dev/n/vitest-inherits-dev-server-hmr-port-and-crashes-6c8f73cc5e9d
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: vitest, vite, hmr, port, config

Vitest boots a Vite server and reads your vite config, so server.hmr settings like clientPort 443 make it try to bind that port and fail with EACCES. Workarounds: put a conditional on NODE_ENV so hmr only applies during dev, or cleaner, use a separate vitest.config.js that does not share the server block. Guarding with process.env.NODE_ENV works but fails if vitest also runs with NODE_ENV=development.
