Skip to content

Repository files navigation

portkill

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.

Install

npm (recommended)

npm i -g @logicwind/portkill

Or run without installing:

npx @logicwind/portkill

The package installs two commands on your PATH: portkill and the short alias pk.

From source

git clone https://github.com/logicwind/portkill.git
cd portkill
./install.sh

The installer symlinks portkill.js into a directory on your PATH and adds a pk alias.

Usage

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)

What you see

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.

Why not lsof -i :PORT | xargs kill?

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."

Platform support

  • 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).

Contributing

Issues and PRs welcome. Keep the dependency count at zero.

License

MIT © Logicwind

About

List listening ports grouped by app + working directory, then interactively kill them. Zero dependencies.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages