# 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.

```text
node error listen EADDRINUSE: address already in use after migrating dev server to vite
```

## Steps

1. Note the port in the error (usually 5173). Find what holds it: `lsof -i :5173` on macOS/Linux, or `ss -ltnp | grep 5173`.
   Expected: one line showing a node process and its PID listening on the port.
2. Kill it: `kill [PID]`, escalating to `kill -9 [PID]` if it ignores the first signal. On Windows: `netstat -ano | findstr :5173` to find the PID, then `taskkill /PID [PID] /F`.
   Expected: re-running the lookup shows nothing listening on the port.
3. Start the vite dev server again (`npm run dev` or `npx vite`).
   Expected: vite prints its Local URL with no EADDRINUSE.
4. 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 `strictPort` is 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 `strictPort` off, 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 `lsof` shows 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
