portspy

module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: MIT

README ยถ

๐Ÿ”Œ portspy

See โ€” and kill โ€” whatever's hogging your local ports. In one key.

portspy is a fast terminal UI that lists everything listening on your machine, tells you what it actually is (the project, the dev server, the command, how long it's been up), and lets you kill it with a single keypress. The "why is :3000 taken AGAIN?" problem, solved.

CI Release Go Reference Go Report Card


Try it in one line โ€” no install, no signup, no config:

go run github.com/agenticraptor/portspy/cmd/portspy@latest
 ๐Ÿ”Œ portspy   7 listening  ยท  sort: port                       updated 09:14:02

  PORT   PROTO  PID     PROCESS       UPTIME  ADDRESS    WHAT
  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  3000   tcp    44213   node          6m      localhost  Next.js ยท storefront
โ–Œ 5173   tcp    44980   node          6m      localhost  Vite ยท admin-web      โ–
  5432   tcp    1188    postgres      3d      localhost  PostgreSQL
  6379   tcp    1190    redis-server  3d      localhost  Redis
  8080   tcp    52111   java          12m     *          Spring Boot ยท billing
  8765   tcp    61002   python3       2s      *          api-scratch
  9229   tcp    44980   node          6m      localhost  Vite ยท admin-web

  โ–ธ node /Users/me/code/admin-web/node_modules/.bin/vite --port 5173

  โ†‘/k up ยท โ†“/j down ยท enter details ยท x kill ยท / filter ยท s sort ยท ? help ยท q quit

Press enter for the full story behind a port โ€” including the process lineage โ€” or x to kill it:

        โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ     โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
        โ”‚  :5173/tcp                           โ”‚     โ”‚  Terminate this process?    โ”‚
        โ”‚                                      โ”‚     โ”‚                             โ”‚
        โ”‚  Process   node (pid 44980)          โ”‚     โ”‚  Port      :5173/tcp        โ”‚
        โ”‚  Service   Vite                      โ”‚     โ”‚  Process   node (pid 44980) โ”‚
        โ”‚  Project   admin-web (node)          โ”‚     โ”‚  Uptime    6m               โ”‚
        โ”‚  Root      /Users/me/code/admin-web  โ”‚     โ”‚  Project   admin-web        โ”‚
        โ”‚  Address   localhost                 โ”‚     โ”‚  Service   Vite             โ”‚
        โ”‚  Started   2026-06-15 09:08:14 (6m)  โ”‚     โ”‚  Parent    npm โ† zsh        โ”‚
        โ”‚  Parent    npm โ† zsh                 โ”‚     โ”‚                             โ”‚
        โ”‚                                      โ”‚     โ”‚  node โ€ฆ/.bin/vite --portโ€ฆ   โ”‚
        โ”‚  node โ€ฆ/.bin/vite --port 5173        โ”‚     โ”‚                             โ”‚
        โ”‚                                      โ”‚     โ”‚  [y] yes    [n] cancel      โ”‚
        โ”‚  [x] kill  [X] force  [esc] close    โ”‚     โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
        โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

The :3000 problem

You run npm run dev. "Port 3000 is already in use." Again. So begins the ritual: lsof -i :3000, squint at a PID, kill -9, hope it was the right one. Was that stray process your other project's dev server? A zombie from last week? A database? lsof won't tell you โ€” it gives you a number, not a story.

portspy gives you the story: which project, which dev server, which command, running for how long โ€” for every port at once โ€” and one key to end it.

Why you'll like it

  • It tells you what it is. Not just node (44980), but Vite ยท admin-web. portspy reads each process's working directory to find the owning project (Go, Node, Rust, Python, Ruby, PHP, Javaโ€ฆ) and recognizes common dev servers and databases (Vite, Next.js, Postgres, Redis, Dockerโ€ฆ).
  • Press enter for the full story. A detail view shows the executable, the project root, the exact start time, and the process lineage (npm โ† zsh) โ€” so you know precisely what you're about to kill.
  • One-key kill, done safely. x terminates gracefully (SIGTERM, escalating to SIGKILL); X force-kills. Both confirm first, and portspy never kills itself.
  • Live & searchable. Auto-refreshing table you can filter (/) and sort (s) by port, PID, process, or uptime.
  • Spots the exposed ones. Anything bound beyond loopback is flagged, so a service accidentally listening on 0.0.0.0 jumps out.
  • Scriptable too. portspy list --json for your shell pipelines, and portspy kill 3000 --yes for your Makefiles.
  • One static binary. No runtime, no daemon, no telemetry, no network. Works on macOS, Linux, and Windows.

Install

go install
go install github.com/agenticraptor/portspy/cmd/portspy@latest
Pre-built binaries

Grab a binary for your OS/arch from the Releases page.

Homebrew (macOS / Linux)
brew install agenticraptor/tap/portspy

Available once the Homebrew tap is published โ€” see the note in .goreleaser.yaml to enable it.

From source
git clone https://github.com/agenticraptor/portspy
cd portspy
make install

Quickstart

# 1. Open the interactive table (this is the whole product)
portspy

# 2. Free a port without the TUI
portspy kill 3000

# 3. See what's listening, as JSON, for scripts
portspy list --json | jq '.[] | select(.exposed)'

# 4. Check what portspy can see on your machine
portspy doctor

Full key bindings, flags, and the JSON schema live in docs/usage.md.

How it works

listening sockets โ”€โ”€โ”
 (TCP LISTEN /      โ”‚
  bound UDP)        โ”œโ”€โ–บ map socket โžœ PID โ”€โ”€โ”
                    โ”‚                       โ”‚
per-PID details โ”€โ”€โ”€โ”€โ”˜                       โ”œโ”€โ–บ enrich โ”€โ”€โ–บ render
 (name, command,                            โ”‚     โ€ข project from cwd
  exe, start time,                          โ”‚     โ€ข service from command
  parent lineage)                           โ”‚     โ€ข merge IPv4/IPv6
                                            โ”‚     โ€ข flag exposed binds
                                            โ””โ”€โ–บ  TUI  ยท  table  ยท  JSON
                                                          โ”‚
                                              kill โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  (SIGTERM โžœ SIGKILL,
                                                              confirmed)

Cross-platform socket and process discovery is handled by gopsutil; the TUI is built with Bubble Tea. See docs/platforms.md for per-OS support and the (small) privilege caveats.

Privacy

portspy runs entirely on your machine and makes no network connections โ€” no telemetry, no update checks, nothing. It reads local socket and process information and prints it. The only thing it changes about your system is the processes you explicitly choose to kill.

Contributing

Contributions are very welcome โ€” see CONTRIBUTING.md. Good first issues include new service-detection patterns, a --watch mode for portspy list, and richer Windows process detail. Please also read our Code of Conduct.

License

MIT ยฉ portspy contributors.

Directories ยถ

Path Synopsis
cmd
portspy command
Command portspy shows what is listening on your local ports โ€” with the project and command behind each โ€” and kills it with one key.
Command portspy shows what is listening on your local ports โ€” with the project and command behind each โ€” and kills it with one key.
internal
buildinfo
Package buildinfo exposes version metadata injected at build time via -ldflags.
Package buildinfo exposes version metadata injected at build time via -ldflags.
cli
Package cli wires the portspy command-line interface together.
Package cli wires the portspy command-line interface together.
killer
Package killer terminates processes by PID, escalating from a graceful signal to a forceful one when a process refuses to exit.
Package killer terminates processes by PID, escalating from a graceful signal to a forceful one when a process refuses to exit.
ports
Package ports enumerates the sockets listening on the local machine and enriches each with the process, command, start time, lineage, and project behind it.
Package ports enumerates the sockets listening on the local machine and enriches each with the process, command, start time, lineage, and project behind it.
render
Package render formats listeners for non-interactive output: an aligned text table for humans and stable JSON for scripts.
Package render formats listeners for non-interactive output: an aligned text table for humans and stable JSON for scripts.
tui
Package tui implements the interactive portspy terminal UI built on Bubble Tea: a live, filterable, sortable table of listening ports that you can kill with one key.
Package tui implements the interactive portspy terminal UI built on Bubble Tea: a live, filterable, sortable table of listening ports that you can kill with one key.

Jump to

Keyboard shortcuts

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