Port Already in Use: Find and Kill the Process
"Address already in use" means something is already sitting on your port. Here's how to find exactly what — and free it up safely.
You start your app and it dies instantly with address already in use or port is already allocated. The message is literal: another process is already listening on that port, and two programs can't share one. The fix is to find it and decide what to do.
Find what's on the port
To see which process holds port 3000:
lsof -i :3000
That prints the process name and its PID (process ID). On systems without lsof, this works too:
ss -ltnp | grep :3000
Decide before you kill
Often it's just an old copy of your own app that didn't shut down cleanly — safe to stop. But check the process name first. If it's something you don't recognise or a service you need, killing it blindly can cause new problems.
Free the port
Once you've confirmed the PID (say it's 4821):
kill 4821
If it refuses to stop, force it:
kill -9 4821
Reach for
kill -9only after a normalkillfails — it gives the process no chance to clean up after itself.
The cleaner long-term fix
If this keeps happening with your own app, the real issue is usually that previous runs aren't shutting down properly. Make sure you stop the app cleanly (Ctrl+C in its terminal, or a proper stop command) rather than just closing the window, and old processes won't pile up holding ports.
The takeaway
"Port already in use" is one of the friendlier errors — it tells you exactly what's wrong. Find the process with lsof/ss, confirm it's safe to stop, and kill it. Two minutes, every time.
Stop reading, start building
This pairs with a hands-on BytExplorer course — do it on your own machine and actually keep the skill.