whoport
Find out who is holding a port, and take it back.
whoport lists every listening port on your machine next to the process that owns it: its name, PID, user, how long it has been running, and the directory it was started from. With five dev servers running, node on port 3000 tells you nothing. ~/code/shop does.
Install
go install github.com/GutoPin/whoport@latest
Requires Go 1.24 or newer. Built for Linux and macOS; so far it has only been run on Linux.
Update
whoport --version # version and the commit it was built from
whoport update # install the latest main branch
update runs go install github.com/GutoPin/whoport@main for you, straight from GitHub, so it needs Go and git on your PATH.
Use
whoport # interactive view
whoport 3000 # who has port 3000
whoport kill 3000 # stop whoever has port 3000
Interactive view
The table refreshes every two seconds. The pane under it shows the full command line, working directory and start time of the selected row.
| Key |
Action |
↑ ↓ or j k |
Move |
/ |
Filter by port, name, command, directory or user |
s |
Change sort order: port, name, newest |
x |
Stop the process (SIGTERM), after confirming |
X |
Force kill (SIGKILL), after confirming |
r |
Refresh now |
S |
Reopen the view with sudo, to see and stop ports other users own |
esc |
Clear the filter |
q |
Quit |
Stopping a process always asks first:
Scripting
whoport --json # everything, as JSON
whoport --json 3000 # one port
whoport kill 3000 --yes # no confirmation prompt
whoport kill 3000 --force # SIGKILL instead of SIGTERM
whoport --udp # include UDP sockets
whoport | grep node # piping prints a plain table
whoport <port> exits with status 1 when nothing is listening, so it works in shell conditions:
whoport 5432 >/dev/null || docker compose up -d db
Make it yours
whoport reads an optional JSON file at ~/.config/whoport/config.json (or $XDG_CONFIG_HOME/whoport/config.json). Every key is optional; anything you leave out keeps its default.
{
"theme": { "accent": "#c2410c" },
"refresh_seconds": 5,
"sort": "newest",
"udp": true
}
whoport config prints the path and every setting with its default. To try a file without installing it, pass --config FILE or set $WHOPORT_CONFIG.
The theme has one colour per role: background, surface, raised, shadow, text, muted, faint, accent, success, warning and danger, each as #rrggbb. Set background to "terminal" to keep your terminal's own background. A misspelled key or a bad colour is reported when the program starts.
This is the same program with a light theme:
The theme in that screenshot
{
"theme": {
"background": "#f4f1ea",
"surface": "#fffdf8",
"raised": "#ece6d8",
"shadow": "#d6cfbf",
"text": "#2b2a27",
"muted": "#7a756a",
"faint": "#c9c2b2",
"accent": "#c2410c",
"success": "#3f7d3a",
"warning": "#a16207",
"danger": "#b42318"
}
}
Notes
- "Up" is the age of the process, not of the socket. Operating systems do not record when a port was opened. For a dev server the two are almost always the same.
- Ports owned by other users show as
needs sudo. The kernel hides their details from you. Press S in the view, or run whoport kill <port> from a terminal, and whoport runs itself again under sudo. It passes its full path and your config file along, so it works even when sudo's PATH leaves out ~/go/bin.
- Without a terminal and without
--yes, kill refuses to run.
Development
go test ./...
go run .
License
MIT