Find what process is listening on a TCP/UDP port, and free it. Agent-friendly: JSON when piped.
Project description
whatport
Find what process is listening on a TCP/UDP port, and free it. The fast, agent-friendly answer to "what's on :5099?" and "kill whatever it is."
Why
"Address already in use." Then the dance: lsof -i :5099, read the pid,
kill, hope. whatport collapses that into one command with structured
output: whatport 5099 tells you the owner; whatport kill 5099 frees it.
JSON when piped, a table in a terminal.
Install
cargo install whatport
Quickstart
# What's on this port?
whatport 5099
# PORT PROTO PID PROCESS USER UPTIME ADDRESS
# 5099 tcp 1234 node ruben 3h12m 127.0.0.1
# Just the data (JSON when piped)
whatport 5099 | jq '.listeners[0].pid'
# Free it (SIGTERM, or --force for SIGKILL)
whatport kill 5099
whatport kill 5099 --force
# Everything that's listening
whatport list
whatport list --proto udp
whatport <port> is shorthand for whatport inspect <port>.
Commands
| command | mutating | what it does |
|---|---|---|
whatport <port> / inspect <port> |
no | the listener(s) on a port: pid, process, command, user, uptime, address |
list |
no | every listening TCP/UDP socket |
kill <port> [--force] |
yes | SIGTERM (or SIGKILL with --force) the owner(s); reports what it signalled |
schema |
no | the clispec v0.2 contract as JSON |
completions <shell> |
no | shell completion script |
Global flags: -o/--output auto\|json\|text (auto = text on a TTY, JSON when
piped) and --proto tcp\|udp\|all.
Output
- Inspect/list:
{"listeners":[{port, proto, addr, pid, process, command, user, uptime_secs}, …]}. - Kill:
{"port", "signal", "killed":[{pid, process, ok, …}], "changed"}.
When the OS won't let you see the owner of a socket you don't own, the port and
protocol are still shown and pid/process are omitted - run with sudo for
full owner details rather than getting a silent gap.
Platforms
macOS and Linux. Pure Rust (netstat2 for the socket table, sysinfo for
process details) - no shelling out to lsof/ss.
Exit codes
| code | meaning |
|---|---|
0 |
success |
1 |
nothing listening on the queried port |
2 |
system error (socket/process table unreadable, or a kill failed) |
3 |
usage error (bad arguments) |
For agents (clispec)
whatport follows The CLI Spec: structured output on
stdout, structured error envelopes on the last line of stderr, and a schema
subcommand whose output validates against clispec.dev/schema/v0.2.json
(checked by the test suite). Read-only commands are mutating: false; kill
is the one mutating: true command.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file whatport-0.1.0.tar.gz.
File metadata
- Download URL: whatport-0.1.0.tar.gz
- Upload date:
- Size: 29.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f676aef113edb3497c74d007bc256c354556b67347ae4b0daecdf83e39c67d30
|
|
| MD5 |
12a26e0080a336867fe3417be1588457
|
|
| BLAKE2b-256 |
1b7a457f262c115d15f350dd02f0b71cf1690c16193ea92dfd2f3c56ffa6c067
|
File details
Details for the file whatport-0.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: whatport-0.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 576.0 kB
- Tags: Python 3, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d741d9d322990cd4ab7fc5b53bc84ad903c68371a6a2020b9cf0b9061eb40429
|
|
| MD5 |
6a8025431d8480f595bdde3f6b0a9ce9
|
|
| BLAKE2b-256 |
d81b5010223c0a6d2dcc867d4c34645e5ad13fb456ed86a253f5e4dafef4693f
|
File details
Details for the file whatport-0.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: whatport-0.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 540.8 kB
- Tags: Python 3, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a026aed1ad1daf690bf0794d5e50e31731cb259efd63e865427f49a194964ad2
|
|
| MD5 |
871f61acd02fd1ca06b9d918909ac579
|
|
| BLAKE2b-256 |
dbb31498f3c6387ce34e14bd5af0282b0c243cf472207f520cf9fd381d1366c8
|
File details
Details for the file whatport-0.1.0-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: whatport-0.1.0-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 453.6 kB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
edbfa3133abef777c41be2cad0cbce39ede25e41b27c9b71a6f899ad718beff9
|
|
| MD5 |
70c7432f3af4da7d64ca0925647f610b
|
|
| BLAKE2b-256 |
01b80686187626953b599903a2ed798f6a79e0819161d73b2e8e38cd1938d883
|
File details
Details for the file whatport-0.1.0-py3-none-macosx_10_12_x86_64.whl.
File metadata
- Download URL: whatport-0.1.0-py3-none-macosx_10_12_x86_64.whl
- Upload date:
- Size: 484.0 kB
- Tags: Python 3, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
712559d2c46a84168148a6ed4133814858c40b00c10a96da8dbc5643dcc5a597
|
|
| MD5 |
a88ec5640a8f15928cced9ed45d140d8
|
|
| BLAKE2b-256 |
84ccd5c4e5715248722c354f75bc92b43260600135d4383f6fc64cdd50be1d91
|