List listening ports grouped by app + working directory, then interactively kill the ones you don't want.
Most "kill port" tools show you a flat list of PIDs. portkill groups them by command and the directory the process was launched from — so two node processes from ~/dev/api collapse into one row, and the one from ~/dev/web stays separate. You see what's running, where it came from, and which ports it owns. Then you pick groups by number and confirm.
No dependencies. Single file. ~300 lines of plain Node.
npm i -g @logicwind/portkillOr run without installing:
npx @logicwind/portkillThe package installs two commands on your PATH: portkill and the short alias pk.
git clone https://github.com/logicwind/portkill.git
cd portkill
./install.shThe installer symlinks portkill.js into a directory on your PATH and adds a pk alias.
portkill interactive list + select + kill (SIGTERM)
portkill -9 use SIGKILL
portkill --list list only, no prompt
portkill --json machine-readable JSON
portkill -f node filter groups containing "node"
portkill 1,3 preselect groups 1 and 3 (still confirms)
portkill 1-3 -y -9 kill groups 1..3, no confirm, force
portkill all -y kill everything (careful)
LISTENING PORTS (grouped by command + working dir)
──────────────────────────────────────────────────────────────────────
[ 1] node — ~/dev/api (3 processes)
ports: 3000, 3001, 9229 pids: 41201, 41202, 41210
/usr/local/bin/node server.js
[ 2] node — ~/dev/web (1 process)
ports: 5173 pids: 41330
/usr/local/bin/node vite
⚠ port 5173 here: * (v4) also in [3] 127.0.0.1 (v4) (shared)
[ 3] Python — ~/dev/scripts (1 process)
ports: 5173 pids: 41501
──────────────────────────────────────────────────────────────────────
Ports bound by more than one group are flagged. Same (host, type) pair on both sides is a real CONFLICT; different host or IP family is just shared.
That works for one port you remember. portkill is for the more common case: "something is squatting on a port, I forget which thing, please show me everything I have running and let me pick."
- macOS — primary target, fully tested.
- Linux — works wherever
lsof,ps, and/proc-style cwd lookups behave the same way as on macOS. Most distros are fine. - Windows — not supported (relies on
lsof).
Issues and PRs welcome. Keep the dependency count at zero.
MIT © Logicwind