whoport

command module
v0.0.0-...-eb9669b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

whoport

Find out who is holding a port, and take it back.

CI MIT license Go version

whoport listing ports, filtering by project and stopping a process

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.

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
esc Clear the filter
q Quit

Stopping a process always asks first:

whoport asking for confirmation before stopping python3 on port 8080

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:

whoport with a light theme and an orange accent

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. Run sudo whoport to see and stop them.
  • Without a terminal and without --yes, kill refuses to run.

Development

go test ./...
go run .

License

MIT

Documentation

Overview

Command whoport shows which process owns each listening port and stops it on request.

Directories

Path Synopsis
internal
config
Package config loads the optional JSON file that changes how whoport looks and behaves.
Package config loads the optional JSON file that changes how whoport looks and behaves.
scan
Package scan finds listening sockets and the processes that own them.
Package scan finds listening sockets and the processes that own them.
tui
Package tui is the interactive view: a live table of listeners with a detail pane, a filter and kill actions.
Package tui is the interactive view: a live table of listeners with a detail pane, a filter and kill actions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL