Your dev server hung. You found its PID and ran kill -9. You start it again, and the port is still in use.

How did that happen?

npm run dev is not one process. On a new Vite project, it's two:

npm run dev └─ node ./node_modules/.bin/vite ← this one holds the port 

A normal kill on npm is fine: npm passes the signal on, and everything exits. But kill -9 can't be caught or passed on. npm dies alone, node keeps running, gets adopted by PID 1, and keeps the port. I tried it on my Mac: after kill -9 on npm, Vite was still listening, and its parent was 1.

While writing this, I checked my Mac for real ones and found one: a Vite dev server from another project, started yesterday morning, still on its port, with parent 1. Whatever started it was long gone.

So you run the script from part 1 of this series to find who holds the port, and kill that too. Next time, the same thing.

With cmdbook, you can see every process a command started, and stopping it stops all of them.

Menu: Show run details

process tree of current running command

Here's how

1. Run your dev server from cmdbook. Save npm run dev as a command and click Run.

2. Open its Process Tree. It shows the same processes, live: npm → node (Vite), and anything they start later. Each with its PID, full command line, CPU and memory, refreshed every 2 seconds. If something is spinning, you can see which one.

3. Click Stop. cmdbook doesn't rely on npm to pass the signal on. It sends it to every process the command started: first SIGTERM, then SIGKILL if something doesn't exit. Start it again, and the port is free.

You don't need part 1's script for your own commands anymore. Keep it for everything else.

Process Tree is part of cmdbook Pro.

Try cmdbook here: printf.app/cmdbook