When a dev server hangs onto a port and refuses to let go, the one-liner you want is lsof -ti :<port> | xargs kill. lsof -ti lists just the PIDs holding that port, xargs pipes them straight into kill, and the offending process is gone — no Activity Monitor, no rebooting, no guessing which node instance is the culprit.
The full post breaks down each flag, covers the SIGKILL escalation (kill -9) when a process ignores the polite signal, and rounds out with related commands worth keeping in muscle memory: lsof -i, netstat -tuln, pgrep, and pkill.
Originally published at andreasbergstrom.dev — read the full post there.
Top comments (0)