You run npm run dev and get this:
Error: listen EADDRINUSE: address already in use :::3000
Something is already listening on port 3000. Usually it's a dev server you started earlier and forgot about: a terminal tab you closed without stopping it, a project from yesterday, or something a coding agent started in the background.
Fix it in two commands
Find what's holding the port:
lsof -i :3000
The output lists the process name and its PID (process ID):
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 41234 you 23u IPv6 0x... 0t0 TCP *:hbci (LISTEN)
Then stop it:
kill 41234
If it won't go, kill -9 41234 forces it. Use that as a last resort: the process gets no chance to clean up.
One-liner, if you're sure whatever is on the port can go:
lsof -ti :3000 | xargs kill
Why it keeps happening
A modern project rarely runs one server. A frontend on 5173, an API on 8000, Postgres on 5432, Redis on 6379, maybe a worker and a docs site. Multiply that by the three projects you touched this week, and nothing on macOS shows you the full picture. Activity Monitor lists processes, not ports. lsof answers one port at a time, and only when you already know which one to ask about.
So stale servers pile up quietly, and you only notice when one blocks the port you need.
What I built instead
I got tired of the lsof ritual, so I built Portlivo, a Mac menu bar app that shows every local dev server and port at once:
- which project each server belongs to, and the command that started it
- whether it's actually answering, plus CPU and memory
- one click to open it in the browser, restart it, tail its logs or kill it
- Homebrew services like Postgres and Redis in the same list
- a QR code to open any server on your phone
When a port clash happens, it notifies you with a Kill holder & retry button, which is the button I'd wanted for years. There's also a command palette, keyboard shortcuts and a devports command-line tool if you'd rather stay in the terminal.
It's a native SwiftUI app for macOS 14 or later, on Apple silicon and Intel. No account, no subscription: a 7-day free trial, then a one-time licence.
Takeaways
-
lsof -i :<port>shows what's on a port;kill <pid>stops it. - Prefer
killoverkill -9. - The port clash is a symptom. The real problem is not being able to see what's running.
If you'd like to see everything at a glance, Portlivo is free to try for 7 days.
Top comments (0)