DEV Community

Mu Micro
Mu Micro

Posted on

When a port is already in use, there is no interactive way to find it — so I built `port-peek`

The problem

When a port is already in use, developers have to chain together lsof, grep, and kill commands to find and stop the offending process — there is no interactive way to scan all listening ports and act on them in one place.

If you've hit EADDRINUSE :::3000 before, you know the ritual: lsof -i :3000, then grep, then kill. Every time.

As a solution, I created port-peek

Interactive TUI for browsing all listening ports and killing the process behind any port with a keypress

Zero dependencies. Run it immediately:

npx port-peek
Enter fullscreen mode Exit fullscreen mode

Output:

port-peek v1.0.0 — Listening ports

  PORT    PID       PROCESS
  3000    91234     node
▶ 5432    823       postgres
  8080    45612     python3
  8888    45990     node

  ↑↓ navigate  Enter kill  r refresh  q quit
Enter fullscreen mode Exit fullscreen mode

Arrow keys to navigate, Enter to kill, r to refresh.

How it works

Pure Node.js using child_process.execSync to run lsof -iTCP -sTCP:LISTEN on macOS (with ss/netstat fallback on Linux), then renders a full-screen ANSI TUI with raw mode stdin for arrow-key navigation and Enter-to-kill. No dependencies.

Why I built it

Found recurring complaints on r/node and r/webdev about the EADDRINUSE error forcing multi-step shell rituals to find and kill the blocking process. The top Stack Overflow answer for 'kill process on port' has millions of views, confirming this is an extremely common pain point. No popular zero-dep npm package provides an interactive alternative — they are all one-shot kill commands that require you to know the port number upfront. An interactive TUI felt like the right format because developers often want to survey all listening ports before deciding which to kill.

Try it

npx port-peek --help
Enter fullscreen mode Exit fullscreen mode

Part of µ micro — one new developer tool, shipped every day.

Top comments (0)