A fast and elegant command-line utility for inspecting and managing TCP ports on macOS and Linux.
lsport helps you quickly identify which processes are occupying TCP ports and terminate them when needed. It provides three modes of operation:
- List mode: View all open TCP ports with process details
- Kill mode: Terminate a process occupying a specific port
- Interactive mode: Browse and manage ports through a TUI menu
- π Fast port scanning using
psutil - π¨ Beautiful terminal output with
rich - π Filter by port state (LISTEN, ESTABLISHED, CLOSE_WAIT)
- π‘οΈ Safe: asks for confirmation before killing processes
- πͺ Force kill option for stubborn processes
- π Interactive TUI for easy port management
- macOS or Linux
- Python 3.9 or higher
pipx(one-time install)
lsport is published on PyPI and installed
in an isolated environment via pipx. This avoids
polluting your system Python, never touches sudo, and gives you a clean
pipx uninstall lsport when you're done.
macOS:
brew install pipx
pipx ensurepathLinux (Debian/Ubuntu):
sudo apt install pipx
pipx ensurepathFor other distributions or platforms see the pipx installation guide.
pipx install lsportThat's it. lsport is now available on your PATH, with its dependencies
isolated in a dedicated virtual environment under ~/.local/share/pipx/.
pipx upgrade lsportpipx uninstall lsportIf you want to run a development build from a local clone (useful for
contributing β see CONTRIBUTING.md):
git clone https://github.com/0xBroom/lsport.git
cd lsport
pipx install --editable .lsport listOutput example:
ββββββββ¬ββββββββββββββ¬βββββββββββ¬βββββββ¬βββββββββββββββββ
β Port β Protocol β State β PID β Process β
ββββββββΌββββββββββββββΌβββββββββββΌβββββββΌβββββββββββββββββ€
β 3000 β 0.0.0.0:3000β LISTEN β 1234 β node β
β 5432 β 127.0.0.1:* β LISTEN β 5678 β postgres β
ββββββββ΄ββββββββββββββ΄βββββββββββ΄βββββββ΄βββββββββββββββββ
# Show only listening ports
lsport list --state listen
# Show active connections
lsport list --state established
# Show ports in close_wait state
lsport list --state close_wait# Interactive kill (asks for confirmation)
lsport kill 3000
# Skip confirmation
lsport kill 3000 --yes
# Force kill (SIGKILL instead of SIGTERM)
lsport kill 3000 --forcelsport interactiveNavigate the interactive TUI to:
- Browse all LISTEN ports
- Select ports by row number or port number
- Kill processes with confirmation
Lists all open TCP ports.
Options:
-s, --state [listen|established|close_wait]- Filter by connection state
Terminates the process occupying the specified port.
Options:
-f, --force- Use SIGKILL instead of SIGTERM-y, --yes- Skip confirmation prompt
Launch an interactive TUI to browse and manage ports.
lsport/
βββ lsport.py # Main CLI application
βββ pyproject.toml # Package metadata and entry point
βββ LICENSE # MIT License
βββ README.md # This file
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
Created by Esteban Encina