A lightweight, blazing-fast CLI utility written in Go to quickly find and terminate processes running on specific network ports.
Never write complex lsof -i :3000 and kill -9 <PID> chains again.
- ⚡ Zero Dependencies: Compiles to a single static binary with no external runtimes needed.
- 🔍 Reliable Lookup: Uses system-level port diagnostics to locate active process PIDs.
- 🐳 Docker Integration: Automatically detects if a port is occupied by a Docker container and shows you how to terminate it.
- 🛡️ Safety Guard: Automatically prevents self-termination if the tool is somehow matching its own process.
- 🎨 Clear Console Logs: Reports how many processes/containers were found, their details, and termination status.
Since killport is compiled into a single static binary with no external dependencies, you do not need Go installed on your machine to run it.
Run the following command to automatically download the correct pre-compiled binary for your operating system and architecture, and install it to /usr/local/bin:
curl -fsSL https://raw.githubusercontent.com/Harshidpatel12/killport/main/install.sh | bashThe script auto-detects your OS and CPU architecture, downloads the correct pre-compiled binary from the Releases page, and installs it to /usr/local/bin.
- Navigate to the Releases page.
- Download the compressed archive matching your operating system and CPU architecture (e.g.,
killport-linux-amd64.tar.gz). - Extract the archive and copy the binary to your system PATH:
tar -xvf killport-linux-amd64.tar.gz chmod +x killport sudo mv killport /usr/local/bin/
- macOS (Homebrew):
brew install Harshidpatel12/tap/killport
- Ubuntu/Debian (APT):
sudo apt install killport
If you have Go installed on your machine, you can download, compile, and install it directly from source:
go install github.com/Harshidpatel12/killport@latestTo kill any local process running on port 3000:
killport 3000Searching for processes on port 3000...
Found 1 process(es) on port 3000: 12345
Killing process with PID 12345...
Successfully killed process 12345.
If the port is occupied by one or more running Docker containers, killport will detect them instead of attempting to terminate host-level proxy processes:
Port 3000 is occupied by Docker container(s):
- Container 'my-web-app' (ID: 8655be0e4e81)
To kill the container(s), run:
killport --container my-web-app
You can terminate Docker containers directly by passing their name, ID, or the published port:
# Kill by container name or ID
killport --container my-web-app
killport -c 8655be0e4e81
# Or kill all containers occupying port 3000
killport --container 3000This project uses standard Go tools and pre-commit hooks to maintain code style and quality.
- Clone the project.
- Initialize pre-commit hooks (requires
pre-commitinstalled):pre-commit install
go test -v ./...This project uses GoReleaser to automatically build cross-platform binaries and upload them to GitHub Releases.
To publish a new release, tag a commit with a version and push:
git tag -a v1.0.0 -m "Release v1.0.0"
git push origin v1.0.0This triggers the Release GitHub Action, which compiles binaries for Linux (amd64/arm64) and macOS (amd64/arm64) and uploads them to the GitHub Releases page automatically. The install.sh script will then download the correct binary for the user's system.
Distributed under the MIT License. See LICENSE for more information.