A cross-platform command-line tool to monitor and manage TCP ports. Written in Rust, it provides a simple way to check which processes are using specific ports and optionally kill them.
- Check specific ports or ranges of ports
- List all listening TCP ports
- Kill processes using specified ports
- Cross-platform support (Linux, macOS, Windows)
- JSON output support
- Human-readable output format
- Clone the repository:
git clone https://github.com/yourusername/port-watcher.git
cd port-watcher- Build the project:
cargo build --release- The binary will be available at
target/release/port-watcher
port-watcher [OPTIONS] [PORTS]PORTS: Ports to check. Can be:- Single port:
3000 - Comma-separated ports:
3000,3001,3002 - Port range:
3000-3005 - Mixed:
3000,3001,3005-3010
- Single port:
-k, --kill: Kill processes found on the specified ports-a, --all: List all listening TCP ports (ignoresPORTSargument if present)--json: Output in JSON format
- Check specific ports:
port-watcher 3000,3001,3002- Check a range of ports:
port-watcher 3000-3005- List all listening ports:
port-watcher --all- Kill processes on specific ports:
port-watcher 3000,3001 --kill- Get JSON output:
port-watcher 3000,3001 --json- List all ports in JSON format:
port-watcher --all --jsonPORT PROTOCOL PID PROCESS NAME STATUS
-------- -------- -------- ------------------------- ----------
3000 TCP 1234 node Listening
3001 TCP 5678 python Listening
3002 TCP N/A N/A Free
[
{
"port": 3000,
"protocol": "TCP",
"pid": 1234,
"process_name": "node",
"status": "Listening"
},
{
"port": 3001,
"protocol": "TCP",
"pid": 5678,
"process_name": "python",
"status": "Listening"
}
]- Linux: Uses
ssornetstatto get port information - macOS: Uses
lsofto get port information - Windows: Uses
netstatto get port information
- Ensure you have Rust installed:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh- Clone and build:
git clone https://github.com/yourusername/port-watcher.git
cd port-watcher
cargo build --release- clap: Command-line argument parsing
- sysinfo: System information gathering
- serde: Serialization/deserialization
- regex: Regular expression support
MIT License
Contributions are welcome! Please feel free to submit a Pull Request.