lsport
A fast and elegant command-line utility for inspecting and managing TCP ports on macOS and Linux.
What is lsport?
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
Features
- 🚀 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
Requirements
- macOS or Linux
- Python 3.9 or higher
pipx(one-time install)
Installation
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.
1. Install pipx (one-time)
macOS:
brew install pipx
pipx ensurepath
Linux (Debian/Ubuntu):
sudo apt install pipx
pipx ensurepath
For other distributions or platforms see the pipx installation guide.
2. Install lsport
pipx install lsport
That's it. lsport is now available on your PATH, with its dependencies
isolated in a dedicated virtual environment under ~/.local/share/pipx/.
Updating
pipx upgrade lsport
Uninstalling
pipx uninstall lsport
Install from source
If 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 .
Usage
List all open ports
lsport list
Output example:
┌──────┬─────────────┬──────────┬──────┬────────────────┐
│ Port │ Protocol │ State │ PID │ Process │
├──────┼─────────────┼──────────┼──────┼────────────────┤
│ 3000 │ 0.0.0.0:3000│ LISTEN │ 1234 │ node │
│ 5432 │ 127.0.0.1:* │ LISTEN │ 5678 │ postgres │
└──────┴─────────────┴──────────┴──────┴────────────────┘
Filter by state
# 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
Kill a process on a specific port
# Interactive kill (asks for confirmation)
lsport kill 3000
# Skip confirmation
lsport kill 3000 --yes
# Force kill (SIGKILL instead of SIGTERM)
lsport kill 3000 --force
Interactive mode
lsport interactive
Navigate the interactive TUI to:
- Browse all LISTEN ports
- Select ports by row number or port number
- Kill processes with confirmation
Command Reference
lsport list
Lists all open TCP ports.
Options:
-s, --state [listen|established|close_wait]- Filter by connection state
lsport kill <port>
Terminates the process occupying the specified port.
Options:
-f, --force- Use SIGKILL instead of SIGTERM-y, --yes- Skip confirmation prompt
lsport interactive
Launch an interactive TUI to browse and manage ports.
Development
Project structure
lsport/
├── lsport.py # Main CLI application
├── pyproject.toml # Package metadata and entry point
├── LICENSE # MIT License
└── README.md # This file
Dependencies
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
Created by Esteban Encina
Acknowledgments
Metadata
Release files for lsport 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| lsport-0.3.1.tar.gz | 10.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lsport-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.2 kB
Release files / lsport-0.3.1.tar.gz
| Download URL | lsport-0.3.1.tar.gz |
|---|---|
| Size | 10.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4c7e810549c0ff92f19f1e5fc511435452585858161c383f0e6efc7e0d98757f
|
|
BLAKE2b-256 checksum How to use checksums |
a08706fc95d88410ed7d70ff9e654874547d644c0c79dd6ba7bf2e53b9866ef1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 9, 2026.
Transparency logRelease files / lsport-0.3.1-py3-none-any.whl
| Download URL | lsport-0.3.1-py3-none-any.whl |
|---|---|
| Size | 7.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8631068d48730cef7bc25ad7f08221f1bc69b14745bf9ac4359a97c36893962a
|
|
BLAKE2b-256 checksum How to use checksums |
9fe6fd6610823c16b588655d74fcffa22490f5312d67d3299aed0ac4951d904f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 9, 2026.
Transparency log