node error listen EADDRINUSE: address already in use after migrating dev server to vite
Fixes node error listen EADDRINUSE: address already in use after migrating the dev server to vite. Use it when vite refuses to start because something already holds the port - usually the old dev server process still running. Key trigger: EADDRINUSE naming the vite port right after the migration.
node error listen EADDRINUSE: address already in use after migrating dev server to vite
TL;DR: Something is already listening on the port (vite defaults to 5173) - almost always the old dev server process still running from before the migration. Find the process on that port and kill it, or point vite at a different port. The error means the port is taken, not that vite is broken.
node error listen EADDRINUSE: address already in use after migrating dev server to viteSteps
Note the port in the error (usually 5173). Find what holds it:
lsof -i :5173on macOS/Linux, orss -ltnp | grep 5173. Expected: one line showing a node process and its PID listening on the port.Kill it:
kill [PID], escalating tokill -9 [PID]if it ignores the first signal. On Windows:netstat -ano | findstr :5173to find the PID, thentaskkill /PID [PID] /F. Expected: re-running the lookup shows nothing listening on the port.Start the vite dev server again (
npm run devornpx vite). Expected: vite prints its Local URL with no EADDRINUSE.If you need both servers up, give vite its own port in the config:
export default { server: { port: 5174 }, };Expected: vite starts on 5174 and both servers coexist.
Use this when
- EADDRINUSE appears the first time you run vite after migrating from webpack-dev-server (or another bundler).
- The port in the error matches the old dev server's port.
- The app worked before the migration and nothing else changed.
Not for this skill when
- EADDRINUSE happens in production or Docker deploys - that is a container port conflict, different fix.
- Vite starts but on an unexpected port (5174, 5175...) - that is vite auto-incrementing because
strictPortis off, not an error. - The address in use is on a remote host, not your machine.
Variant phrasings
- vite dev server port already in use after webpack migration
- Error listen EADDRINUSE 5173 vite
- kill process on port before starting vite
Why it happens
Migrating the config does not kill the old process: the previous dev server (webpack-dev-server, or an earlier vite run in another terminal) is still bound to the port, and the new vite process cannot bind the same one.
Edge cases
- With
strictPortoff, vite silently moves to the next free port - if your app suddenly lives on 5174, a stale process is the reason. - A zombie process owned by another user or a hung CI job can hold the port invisibly - check with elevated privileges if
lsofshows nothing under your user. - Terminal tabs and editor-integrated terminals are the usual hiding spots for the forgotten old server.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_JmkIgOvln4jsYgjfT37UcQ