Skip to content
preraksh10Public

About

Port 3000 already in use? A free Windows tray app to see what's using a port and open, restart or kill local dev servers in one click. Stops nodemon/uvicorn reloaders too, Docker & WSL aware. Portable .exe, no install.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

PortStat — see and stop what's using a port on Windows

Port 3000 already in use? EADDRINUSE? PortStat is a small Windows system-tray app that shows every local dev server listening on a TCP port and lets you open, restart or stop it in one click. No more netstat -ano | findstr :3000 and taskkill /PID … /F.

PortStat demo: list of local dev servers with Open, Restart and Kill buttons

⬇ Download PortStat.exe — portable, no installer, Windows 10/11.

Website: https://preraksh10.github.io/PortStat/

Features

  • Tray icon with a live badge showing how many dev ports are active (3000, 5173, 8000, 8080, … plus any you pin)
  • One list of listening ports with process, PID, command, project folder, memory and uptime. Filter by port, process or folder
  • Kill stops the server and the watcher that would respawn it (nodemon, uvicorn --reload, Flask/Django reloaders, venv launchers)
  • Docker and WSL aware: ports published by Docker are stopped with docker stop <container>; Docker Desktop and WSL networking are never killed
  • Restart relaunches a server with its original command, folder and environment in a new console window, then confirms the port comes back
  • Stop All Dev Servers lists what it will stop and asks first; database ports (PostgreSQL, MySQL, Redis, MongoDB) are skipped
  • Pin/watch custom ports, find and copy a free port, open http://localhost:<port>, open the project folder
  • Global hotkey Ctrl+Alt+P; optional launch on Windows login (Startup-folder shortcut, no registry edits)
  • Safe by design: critical Windows processes (lsass.exe, services.exe, svchost.exe, …) and PortStat itself are never terminated, even as Administrator
  • Command line: PortStat.exe --list, PortStat.exe --kill 3000

Install

Download (recommended)

  1. Download PortStat.exe (always the latest release).
  2. Put it in any folder you like (settings are saved next to it) and run it.

Windows SmartScreen: the exe isn't code-signed yet, so Windows may show "Windows protected your PC". Click More info → Run anyway. You can check the download against SHA256SUMS.txt from the same release:

(Get-FileHash .\PortStat.exe -Algorithm SHA256).Hash

winget / Scoop

Scoop:

scoop bucket add preraksh10 https://github.com/preraksh10/scoop-bucket
scoop install preraksh10/portstat

winget: winget install preraksh10.PortStat (pending review).

From source

Requires Python 3.12+.

git clone https://github.com/preraksh10/PortStat.git
cd PortStat
python -m venv .venv
.venv\Scripts\pip install -r requirements.txt
.venv\Scripts\pythonw.exe portstat.py      # tray app, no console window

Usage

Click the tray icon or press Ctrl+Alt+P to show the window. Launching PortStat again while it's running brings the existing window to the front.

Key Action
Ctrl+Alt+P Show / hide the window (global)
Ctrl+F Focus the filter box
Up / Down Move selection
Enter Open the selected port in the browser
Delete Stop the selected server (asks first)
F5 Rescan
Esc Hide to tray

Click a port number to copy its URL, the PID line to copy the PID, and the folder to open it in File Explorer.

Command line

PortStat.exe --list        # list all listening TCP ports
PortStat.exe --kill 3000   # stop whatever serves :3000 (exit code 1 if it couldn't)
PortStat.exe --version

Run from source with python portstat.py --list.

Configuration

Settings are stored in config.json next to PortStat.exe (or the project folder when run from source), created on first run:

Key Default Meaning
pinned_ports [] Extra ports treated as dev ports and listed first
ignored_executables Windows services Hidden in "All" view when hide_system_noise is on
hide_system_noise true Hide background Windows services
dev_ports_only true Show only dev/pinned ports
poll_interval_sec 3.0 Tray badge refresh interval (1–300)
window_width / window_height 660 / 540 Window size in logical (DPI-independent) pixels

If config.json isn't valid JSON, PortStat starts with defaults and keeps a copy as config.corrupt.json. A single invalid setting only resets that setting.

PortStat writes a small rotating log, portstat.log (up to 512 KB plus 2 older copies), next to config.json. It records stops, restarts, configuration problems and unexpected errors.

How it compares

PortStat netstat + taskkill TCPView npx kill-port
Tray icon + hotkey ✅ — — —
Stops reloaders that respawn the server ✅ — — —
Docker container aware ✅ — — —
Restart with original command ✅ — — —
No Node.js required ✅ ✅ ✅ —

Development

.venv\Scripts\pip install -r requirements-dev.txt
.venv\Scripts\python.exe -m unittest discover -s tests -t . -v
.venv\Scripts\python.exe scripts\build.py        # build\PortStat.exe + SHA256SUMS.txt
.venv\Scripts\python.exe scripts\generate_ico.py # regenerate assets\icon.ico

The build uses Nuitka (single-file exe). If Visual Studio Build Tools aren't installed, Nuitka downloads a MinGW compiler on first use. The exe is built with --windows-console-mode=attach, so --list prints in a terminal while the tray app opens no console window. Output may appear after the prompt returns.

Contributing

  • main is protected and only receives pull requests from develop.
  • Branch from develop, open your pull request against develop, and make sure the test check passes.
  • Releases are tagged from main (vX.Y.Z); GitHub Actions builds PortStat.exe and SHA256SUMS.txt and publishes the release.

Project layout

portstat.py    launcher (also the build entry point)
src/
  main.py      CLI, single-instance guard, hotkey, wiring
  config.py    settings, logging, shared constants, data classes
  scanner.py   listening-port scan, Docker port mapping, filtering
  killer.py    safe stop/restart, supervisor detection, Docker stop, autostart
  tray.py      tray icon, badge rendering, background poller
  ui_popup.py  CustomTkinter window
tests/         unit tests (python -m unittest)
scripts/       build script, icon generator
website/       GitHub Pages site (deployed by .github/workflows/pages.yml)
assets/        app icon, README screenshots
packaging/     winget and Scoop manifests

License

MIT

About

Port 3000 already in use? A free Windows tray app to see what's using a port and open, restart or kill local dev servers in one click. Stops nodemon/uvicorn reloaders too, Docker & WSL aware. Portable .exe, no install.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages