cd ../notes

TIL ·

Find and kill the process using a TCP port

When a port is already in use, find who owns it before reaching for a reboot:

bash
ss -ltnp 'sport = :8080'
lsof -i :8080
fuser 8080/tcp

ss -ltnp shows the PID in the users:(...) column (use sudo to see other users’ processes); lsof -i :8080 lists the open sockets; fuser 8080/tcp prints just the PIDs. Then kill it:

bash
fuser -k 8080/tcp
# or: kill $(lsof -t -i :8080)

-k sends SIGKILL by default — use fuser -k -TERM 8080/tcp first if you want to let the process clean up.