@lowdep/port-kill
v1.0.0
Published
Find and kill the process listening on a port — cross-platform (Windows/Mac/Linux), zero dependencies
Downloads
80
Maintainers
Readme
port-kill
Find and kill whatever process is holding a port. Cross-platform (Windows, macOS, Linux), zero dependencies.
No more memorizing this:
# Mac/Linux
lsof -ti:3000 | xargs kill -9
# Windows
netstat -ano | findstr :3000
taskkill /PID <pid> /FJust:
port-kill 3000Install
npm install -g port-killOr without installing:
npx port-kill 3000Usage
port-kill 3000 # Kill whatever is on port 3000
port-kill 3000 8080 # Multiple ports
port-kill 3000,8080,5432 # Comma-separated
port-kill 3000-3010 # Range
port-kill :3000 # Leading colon is fine
port-kill 3000 --list # Show the process, don't kill
port-kill 8080 --force # Force-kill (SIGKILL / taskkill /F)
port-kill 3000 --yes # Skip the confirmation promptExample Output
port-kill checking port(s): 3000
:3000 → node pid 24180
kill 1 process(es)? [y/N] y
✓ Killed node pid 24180 on :3000
1 killedWith --list (dry run):
port-kill checking port(s): 3000, 8080
:3000 → node pid 24180
:8080 → python pid 9921How It Works
| Platform | Find process | Kill |
|---|---|---|
| Windows | netstat -ano | taskkill /PID /T |
| macOS / Linux | lsof → fuser → ss (first available) | SIGTERM / SIGKILL |
By default it sends a graceful termination (SIGTERM / taskkill without /F) and waits briefly to confirm the process exited. If the process is still alive after the grace period, it automatically escalates to a forced kill (SIGKILL / taskkill /F) — because you asked to free the port. Output marks these as (forced).
Use --force to skip straight to a forced kill (useful on Windows, where console processes can't be stopped gracefully anyway).
vs. Alternatives
| Tool | Runtime | Windows | Zero-dep |
|---|---|---|---|
| lsof \| xargs kill | shell | ❌ | ✓ |
| kill-port (npm) | Node | ✓ | ❌ |
| fkill (npm) | Node | ✓ | ❌ |
| port-kill | Node | ✓ | ✓ |
Exit Codes
0— all matched processes killed (or nothing was listening)1— one or more processes could not be killed (try--forceor elevated privileges)
License
MIT
Keywords
kill port · kill process on port · free port · kill-port alternative · fkill alternative · lsof kill · release port · eaddrinuse · cross-platform · zero dependencies
Built to solve, shared to help — Rushabh Shah 🛠️✨
One of 40+ zero-dependency developer CLI tools — no node_modules, ever.
