Port Already in Use

Symptom

Error: listen EADDRINUSE: address already in use :::3000
# or
bind: Address already in use

Find what’s using the port

# macOS / Linux
lsof -i :3000
 
# Linux
netstat -tulpn | grep 3000
ss -tulpn | grep 3000
 
# Output shows PID
# COMMAND  PID   USER   FD   TYPE ...
# node    1234   me     23u  IPv6 ...

Fix it

# Kill the process
kill 1234
 
# Force kill
kill -9 1234
 
# One-liner
lsof -ti :3000 | xargs kill
 
# Or just use different port
PORT=3001 npm start

Why this happens

  • Previous process didn’t shut down cleanly
  • Multiple terminals running same thing
  • Something else using that port (check before killing)
  • Docker container still running

Docker specific

docker ps | grep 3000
docker stop <container_id>