How to Find and Kill a Process Using a Specific Port in Linux
Find which process is using a port with lsof -i or netstat, then kill it by PID — useful when 'Address already in use' blocks a server from starting.
Published September 21, 2026
When you see 'Address already in use', another process is already bound to the port you're trying to use. lsof -i :PORT finds exactly which process it is.
lsof -i :3000
kill -9 <PID>Steps
- Run lsof -i :3000 (replacing 3000 with your port) to list any process using that port, including its PID
- Confirm it's actually the process you expect to kill — don't blindly kill unfamiliar PIDs on a shared server
- Run kill <PID> for a graceful shutdown, or kill -9 <PID> to force-terminate a process that won't respond to a normal kill
How it works
Only one process can bind to a given TCP port at a time. If a previous instance of your server didn't shut down cleanly, it can keep holding the port, blocking a new instance from starting.
Things to watch for
- On systems without lsof, ss -tulpn or netstat -tulpn | grep :3000 achieves the same result
- kill -9 (SIGKILL) doesn't give the process a chance to clean up — prefer a plain kill (SIGTERM) first and only escalate to -9 if the process doesn't exit
FAQ
Why does my server say 'port already in use' right after I stopped it?
The OS can hold a port in a TIME_WAIT state briefly after a process exits. If it persists longer than expected, check for a duplicate/zombie process still holding it with lsof -i :PORT.