Introduction to kport
kport (or port-killer) is a standalone, single-binary network port inspector and process termination utility written in Rust. It was built to eliminate the tedious cycles of running lsof -i :3000, parsing process IDs manually, and invoking kill -9.
- Zero Subshells: Reads kernel socket structures directly instead of spawning sub-processes.
- Contextual Awareness: Identifies frameworks (Next.js, Vite, Postgres, Redis) and process working directories.
- Safe by Default: Graceful
SIGTERMescalation beforeSIGKILLand daemon protection safeguards.
Installation
kport is distributed across all major package managers:
Universal Shell Script (Linux & macOS)
curl -sSf https://raw.githubusercontent.com/neuralshyam/kport/main/install.sh | sh
Cargo (Rust Crates.io)
cargo install kport
NPM / Bun (Zero-Install Execution)
bunx @neuralshyam/kport 3000
# or globally
bun add -g @neuralshyam/kport
Homebrew (macOS / Linux)
brew install neuralshyam/tap/kport
Arch Linux AUR
yay -S kport-bin
Quick Start
After installation, both port-killer and kport commands are available on your system path.
# 1. Kill a blocking port
kport 3000
# 2. Launch interactive terminal UI
kport
# 3. List active ports in table format
kport --list
Single & Multi-Port Termination
Pass one or more port numbers directly as arguments. kport resolves their active processes and terminates them cleanly:
# Terminate process on port 3000
kport 3000
# Terminate multiple ports simultaneously
kport 3000 8080 5432 6379
# Skip graceful SIGTERM and send SIGKILL immediately
kport 3000 --force
Port Ranges & Wildcards
Manage microservice clusters and container port maps easily using range expressions and wildcard prefixes:
# Range syntax (inclusive)
kport 3000..3010
kport 8080-8085
# Wildcard prefix matching
kport 80* # Matches 80, 8080, 8000, 8081...
kport 54* # Matches 5432, 5435...
Dev & DB Presets
Use built-in presets to sweep common development ports without memorizing port numbers:
kport :dev
Sweeps web dev servers:
3000, 3001, 5173, 8000, 8080, 4200, 8888, 5000
kport :db
Sweeps database servers:
5432 (Postgres), 3306 (MySQL), 6379 (Redis), 27017 (Mongo)
Live HTTP / TCP Prober
Send a lightweight non-blocking probe to verify service health, latency, HTTP status, server header, and HTML <title> without opening a browser:
kport probe 3000
# or
kport --probe 3000
Zombie / Orphan Process Sweeper
When an IDE, terminal tab, or Docker container crashes unexpectedly, background Node or Python processes often become orphans (PPID == 1), hogging RAM and blocking ports.
# Scan and terminate all orphaned processes holding ports
kport --zombies
Kill & Exec Chaining
Free a port and immediately spawn your development server in the same terminal session:
kport 3000 --exec "bun dev"
kport 5173 --exec "npm run dev"
kport 8000 --exec "cargo run"
Structured JSON Output
Pass --json with --list to get machine-readable output for integration with scripts, CI pipelines, or editor extensions:
kport --list --json | jq '.[] | select(.port == 3000)'
Monorepo Config (kport.toml)
Place a kport.toml in the root of your project or monorepo to standardize dev port management across team members:
# kport.toml
[services]
frontend = 3000
backend = 8000
database = 5432
redis = 6379
storybook = 6006
# Check active/down status of all configured services
kport status
# Reset and free all project ports in one command
kport reset
Kernel Socket Architecture & Safety
kport avoids the heavy latency of spawning shell pipelines like lsof or netstat by directly parsing native kernel structures:
- Linux: Scans
/proc/net/tcp,/proc/net/tcp6,/proc/net/udpand matches socket inodes directly against/proc/<pid>/fd/*. - macOS: Uses native
libprocand low-overheadlsof -Frecord streams. - Windows: Direct Win32 socket table inspection.
- Graceful Escalation: Sends
SIGTERMand monitors process exit for up to 500ms before falling back toSIGKILL. - Daemon Guard: Rejects termination of system processes (PID โค 1,
sshd,systemd,dockerd) unless explicitly overridden with--force.