@ugurkellecioglu/fkp
v0.1.1
Published
Fast kill port — kill processes on one or more ports, cross-platform. Optional --tcp / --udp filters.
Maintainers
Readme
fkp — fast kill port
Kill processes listening on one or more ports. Cross-platform (macOS, Linux, Windows). Zero dependencies.
npx @ugurkellecioglu/fkp 3000
npx @ugurkellecioglu/fkp 3000 8080 5173
npx @ugurkellecioglu/fkp --tcp 3000 # leave clients alone, only kill the listener
npx @ugurkellecioglu/fkp --udp 53 # kill UDP bindings (DNS, game servers, etc.)Why another kill-port tool?
Compared to the two popular alternatives:
kprunslsof -i:PORT | xargs killall, which matches by process name.kp 3000will kill everynode(orpython, etc.) process on your machine, not just the one on port 3000. Single port only.kill-porttargets PIDs correctly, but as an existence check it runslsof -i -P— which enumerates every network socket on the system. On a busy dev box that alone takes multiple seconds before it even starts killing.
fkp does neither. It runs one targeted lsof -ti:<ports> and one kill -9 with all PIDs, no shell, no deps.
Flags
| Flag | Behavior |
|---|---|
| (none) | Fastest. Kills every process with a socket on the port(s) — listeners and any connected clients. |
| --tcp | Only kills TCP listeners. Safe mode — won't touch processes (e.g. Chrome, curl, psql) that happen to have an open connection to the port. |
| --udp | Only kills UDP sockets bound to the port. |
| --tcp --udp | Union of both filtered queries. |
The default prioritizes speed. Pass --tcp when you want "kill the server, leave my client open" semantics.
Benchmark
macOS, 5 runs, wall-clock including Node startup:
| Scenario | fkp (default) | fkp --tcp | kp | kill-port | |---|---|---|---|---| | 1 port | 263 ms | 263 ms | 288 ms | 6495 ms | | 3 ports | 266 ms | 264 ms | ~480 ms (N invocations) | ~5700 ms |
fkp stays flat across port count — one lsof and one kill call regardless of how many ports. kp grows linearly (one Node startup per port). kill-port is bottlenecked on the system-wide lsof -i -P scan.
How it works
- macOS / Linux:
lsof -ti:3000,8080,5173→kill -9 <pids>. With--tcp:lsof -ti tcp:<ports> -sTCP:LISTEN. With--udp:lsof -ti udp:<ports>. - Windows: one
netstat -anoparse →taskkill /F /PID x /PID y /PID z. Flags filter the protocol/state in the parser. - Uses
execFile(no shell) for speed and safety. - Exits 0 whether or not a process was found.
Install
npm i -g @ugurkellecioglu/fkp
# then
fkp 3000
# or one-off
npx @ugurkellecioglu/fkp 3000License
MIT
