Getting Started
ports finds every dev server on your machine and gives it a name — http://shop.localhost instead of http://localhost:3000. Start servers the way you already do, from a terminal, an editor, docker compose or a coding agent; ports works out what each one is and names it after its project. Nothing to wrap, nothing to declare. See what's running, reach it by name, stop it safely.
- http://localhost:3000 # shop, or whichever app got there first
+ http://shop.localhost # shop, on any port, after any restartInstall
$ curl -fsSL https://ports.tools/install | shOne static binary for macOS, Linux and Windows, WSL included — curl on macOS and Linux, npm everywhere. No runtime, no account; npx @pyjeebz/ports runs it without installing.
It finds what's running
Run ports on your machine as it is. It reads every listener and works out what each one is — the framework, the project it belongs to, the container behind docker-proxy, how long it's been up. None of these were started by ports:
$ ports
PORT PROCESS PROJECT UPTIME URL
3000 Next.js shop 14m http://localhost:3000
8000 FastAPI shop 14m http://localhost:8000
5432 PostgreSQL docker: shop-db 2d
5173 Vite admin 3h http://localhost:5173Start the router once, and each of them answers at a name — the servers already running, and every one you start from now on, wherever you start it. It runs in the background, and again at login.
$ ports proxy start
✓ routing *.localhost on :80 — a systemd user unit, started at login
$ ports
PORT PROCESS PROJECT UPTIME URL
3000 Next.js shop 14m http://shop.localhost
8000 FastAPI shop 14m http://api.shop.localhost
5432 PostgreSQL docker: shop-db 2d
5173 Vite admin 3h http://admin.localhostNothing restarted, and nothing about how you start servers changed. ports here narrows the list to the project you're in, ports find postgres searches it, and ports doctor 3000 explains a port that won't free.
Where names come from
A name comes from the project — its package.json name, or its folder — and the app's place in it, never from the port:
| Where it runs | Its name |
|---|---|
~/shop | shop.localhost |
~/shop/apps/api | api.shop.localhost |
a worktree of shop on fix/ui | ui.shop.localhost |
the web service of a compose project in ~/shop | web.shop.localhost |
| anything else, named by you | ports alias stripe 4242 |
Two projects that are both called shop are told apart once — the second becomes shop-client, after its parent folder — and remembered, so they never swap. Each app gets its own origin, so cookies and local storage stop leaking between them.
How it works
The router listens on this machine's loopback, and nowhere else. Browsers already send every *.localhost name there, so nothing needs configuring. For each request it reads the Host header, looks the name up, and passes the request on — WebSockets and event streams included, so hot reload works as before.
The route table isn't declared anywhere. ports builds it from the machine itself, every two seconds: which processes listen, which project each belongs to, which port is the app and which its debugger. A name comes from the project, never the port, so a server that restarts somewhere else keeps it.
Shop
A Host that isn't one of its names is refused with a 421. That's what keeps a website from reaching your dev servers by pointing its own domain at 127.0.0.1.
Stop it safely
$ ports stop api.shop --expect fastapi
✓ stopped FastAPI (:8000)--expect is the guard: if anything the stop would reach isn't what you said, nothing is stopped. Set PORTS_REQUIRE_EXPECT=1 and every stop must carry it. A stop sends SIGTERM, waits, then SIGKILL; another user's process is never touched.
Let ports pick the port
You never need ports run to get a name — the servers you start yourself are found. It's for when you'd rather ports chose the port: it picks a free one, hands it over the way the framework takes one — PORT, or --port for Vite, Astro and Angular — and names the server for as long as it runs.
$ ports run -- npm run dev
→ http://shop.localhost (:4123)When the project is already up, it says where instead of starting a second copy on the next free port:
$ ports run -- npm run dev
ports: shop is taken by another ports run (pid 48211, :4123) — name this one: ports run shop-2 -- …For coding agents
Agents start a second dev server on the next free port, then test the wrong one. With ports they see what's already up — the servers you started included — reuse it, and reach it by name.
ports here || (ports run -- npm run dev &) # reuse it if it's up
ports wait shop --http # until it answers
curl "$(ports url shop)/api/health" # by name, never a guessed portEvery command speaks JSON with --json, and exits 0 when it found something, 1 when it didn't, 2 when it was called wrong. The MCP server offers list, here, find, url, wait, stop and doctor as tools; it starts nothing, and its stop always needs expect.
Names for every client
Browsers and curl send every *.localhost name to this machine on their own. Node's fetch, Python and Go ask the system instead, and on Windows — or a Linux that skips systemd-resolved — the system doesn't know them.
$ ports doctor
· this machine's resolver doesn't find shop, api.shop — browsers and curl reach them, but Node's fetch, Python and Go clients don't
→ `ports hosts sync` writes them to the hosts file; meanwhile `ports url --local <name>` gives an address every client reaches
$ ports hosts sync
✓ /etc/hosts resolves 2 name(s) for every client: api.shop, shopThe names go in one marked block, and nothing else in the file is touched. ports hosts clean takes them out again.
What ports won't do
Listen beyond this machine
The router binds 127.0.0.1 and ::1, and answers only the .localhost names it knows.
Run what you didn't ask for
Only ports run starts a process, and only the command you gave it. No restarts, no supervising.
Route someone else's server
It routes the dev servers of the user it runs as, and stops only yours.
Phone home
One static binary. No account, no cloud, no telemetry.
Every command and flag is in the docs; how names are made is in Names, the router in Router, and the agent setup in Agents. The source is on GitHub.