Portless Integration
Named .localhost URLs for local development. Replaces localhost:3000 with https://myapp.localhost.
Full CLI reference: Load Read("references/upstream.md") for complete command docs.
New in 2026-04 → 2026-07 (portless 0.10.x → 0.15.0)
portless doctor (0.15.0) — read-only diagnostics that check Node.js, the state directory, proxy liveness, route entries, hostname resolution, HTTPS CA trust, and LAN prerequisites, then print suggested fixes. Run it before filing an issue or when a .localhost URL won't resolve.
- HTTP/2 Host forwarding fix (0.15.0) — the proxy now forwards the HTTP/2
:authority as Host to HTTP/1.1 backends, fixing apps that read Host and previously saw 127.0.0.1 for browser traffic. --force takeover cleanup now removes only routes still owned by the exiting process, so a forced takeover no longer deregisters the new owner's route.
--ngrok flag (0.14.0) — share an app publicly via ngrok while local access keeps its .localhost URL. Pair with the existing Tailscale/Funnel options when you need a public URL without giving up the named-subdomain dev experience.
- Node.js 24+ required (0.13.1, BREAKING) — the proxy and CLI now require Node.js 24 or newer; older runtimes are unsupported. This release also hardens startup-service persistence so
.localhost URLs survive reboot reliably.
- State directory moved to
~/.portless (0.11, BREAKING) — state relocated from scattered/temp locations to ~/.portless; override with PORTLESS_STATE_DIR. Old state from pre-0.11 installs is not migrated automatically.
- OS startup service (0.13.0) —
portless service install / service status / service uninstall register a native startup service for the HTTPS proxy across macOS launchd, Linux systemd, and Windows Task Scheduler. .localhost URLs survive reboot without a manual portless proxy start. portless clean removes the service alongside CA + hosts cleanup.
- Tailscale readiness preflight (0.13.0) —
--tailscale and --funnel now validate Tailscale HTTPS + Funnel prerequisites before starting the child process, surfacing actionable errors instead of hanging during registration.
- Tailscale integration (0.12.0) —
--tailscale shares your app over your tailnet with automatic HTTPS on port 443; --funnel exposes it publicly via Tailscale Funnel. Apps receive PORTLESS_TAILSCALE_URL so they can reference their own public address. portless list now shows tailnet URLs.
- Zero-config mode (0.11.0) — bare
portless auto-discovers dev scripts from package.json. Multi-app monorepos get automatic subdomain assignment; Turborepo task-graph integration is wired in. portless.json config file supported. --script overrides the default "dev" script.
portless prune — removes orphaned dev servers and stale Tailscale registrations.
portless clean (extended) — now also tears down Tailscale registrations alongside CA + hosts cleanup.
- Rsbuild + VitePlus auto-port injection — same auto-wiring as Vite/Next.
- State directory moved to
~/.portless (was scattered).
- HTTPS on 443 by default (breaking from 0.9.x http:1355). Valid cert, no setup.
--no-tls reverts.
NODE_EXTRA_CA_CERTS auto-injected (0.10.2) into child processes — node HTTPS calls trust portless CA with zero setup.
--wildcard subdomains — https://*.myapp.localhost for multi-tenant / preview routing.
portless alias <name> <port> — map a docker-compose / emulate port to a named URL without a long-running run process.
portless clean — full teardown: stops proxy, removes CA, wipes state, cleans /etc/hosts.
--lan mode — mDNS .local hostnames reachable across wifi (phone, tablet, other machines) without router config.
- Fixed app ports —
--app-port 3000 / PORTLESS_APP_PORT for tools that need a known port (debuggers, docker).
- hosts-sync on by default for Safari compat (disable with
PORTLESS_SYNC_HOSTS=0).
- HTTP/2 HMR fixes for Vite/VitePlus/Next.js dev — websocket upgrades no longer break under h2.
- Expo / React Native support —
portless run expo start gives Metro a stable URL for device QR codes.
When to Use
- Starting a dev server that agents or browser tests will target
- Running multiple services locally (API + frontend + docs)
- Working in git worktrees (branch-named subdomains)
- Local OAuth flows (stable callback URLs)
- Connecting emulate API mocks to named URLs
Quick Start
# Instead of: npm run dev (random port)
portless run npm run dev
# → https://myapp.localhost (stable, named, HTTPS on 443 — default in 0.10+)
# Multi-service
portless run --name api npm run dev:api
portless run --name web npm run dev:web
# → https://api.localhost, https://web.localhost
# LAN mode (0.10.0) — reachable from phone/tablet via mDNS
portless proxy start --lan
portless run npm run dev
# → https://myapp.local (resolves across the local network, no router config)
# Full teardown (0.10.1) — stops proxy, removes CA, wipes state, cleans /etc/hosts
portless clean
# Boot persistence (0.13.0) — install native startup service (launchd / systemd / Task Scheduler)
portless service install
portless service status
# Removed automatically by `portless clean`, or explicitly:
portless service uninstall
0.10.x breaking change: default switched from https://app.localhost to https://app.localhost on port 443. Use --no-tls to revert. NODE_EXTRA_CA_CERTS is injected into child processes automatically (0.10.2) — no manual cert setup. /etc/hosts is synced automatically for Safari; disable with PORTLESS_SYNC_HOSTS=0.
Framework-Specific Setup
Load Read("references/framework-integration.md") for full framework recipes.
Most frameworks (Next.js, Vite, Express) work with portless run <cmd>. Some need explicit flags:
| Framework |
Auto-detected? |
Extra flags needed |
| Next.js |
Yes |
None |
| Vite / Astro |
Yes |
None |
| Express / Fastify / Hono |
Yes |
None (reads PORT env var) |
| Ruby on Rails |
Yes |
None |
| FastAPI / uvicorn |
No |
--port $PORT --host $HOST |
| Django |
No |
$HOST:$PORT positional arg |
Why .localhost?
| Feature |
.localhost (RFC 6761) |
127.0.0.1:PORT |
/etc/hosts hack |
No /etc/hosts editing |
Yes |
Yes |
No |
| HTTPS with valid cert |
Yes |
No |
Manual |
| Wildcard subdomains |
Yes |
No |
No |
| Works in all browsers |
Yes |
Yes |
Varies |
| Cookie isolation per service |
Yes |
No |
Yes |
| No port conflicts |
Yes |
No |
Yes |
Key Environment Variables
When portless runs your command, it injects:
| Variable |
Value |
Use in agents |
PORT |
Assigned ephemeral port (4000-4999) |
Internal only |
HOST |
127.0.0.1 |
Internal only |
PORTLESS_URL |
https://myapp.localhost |
Use this in agent prompts |
NODE_EXTRA_CA_CERTS |
Path to portless CA (auto-injected 0.10.2) |
Child node processes trust portless certs without setup |
Toggle env vars
| Variable |
Effect |
PORTLESS=0 |
Bypass portless entirely (CI) |
PORTLESS_SYNC_HOSTS=0 |
Disable auto /etc/hosts sync (default: on in 0.10.1+) |
PORTLESS_STATE_DIR |
Override state dir (default: ~/.portless or /tmp/portless for privileged ports) |
OrchestKit Integration Patterns
1. Agent-Accessible Dev Server
# Start with portless, then agents can target PORTLESS_URL
portless run npm run dev
# In ork:expect or agent-browser:
agent-browser open $PORTLESS_URL
2. Emulate + Portless (Named API Mocks)
# Register emulate ports as named aliases
portless alias github-api 4001
portless alias vercel-api 4000
portless alias google-api 4002
# Now agents can target:
# https://github-api.localhost — GitHub emulator
# https://vercel-api.localhost — Vercel emulator
3. Git Worktree Dev
# In worktree for feature/auth-flow:
portless run npm run dev
# → https://auth-flow.myapp.localhost (auto branch prefix)
4. Bypass in CI
# Disable portless in CI — direct port access
PORTLESS=0 npm run dev
Anti-Patterns
| Don't |
Do Instead |
Hardcode localhost:3000 in tests |
Use PORTLESS_URL or process.env.PORTLESS_URL |
| Run portless in CI |
Set PORTLESS=0 in CI environments |
| Use numeric ports in AGENTS.md |
Document the portless URL |
References
| File |
Content |
references/upstream.md |
Full portless CLI reference (synced from Vercel) |
references/upstream-oauth.md |
OAuth callback patterns with stable URLs |
references/framework-integration.md |
Framework recipes (FastAPI, Django, Docker, gotchas) |
checklists/new-project-setup.md |
Step-by-step: add portless to a new project |
1---2name: portless3description: Named HTTPS .localhost URLs with portless (v0.15.x). Eliminates port collisions, gives agents stable URLs, adds branch-named subdomains for git worktrees, LAN mode (--lan), and Tailscale sharing. Use when setting up a local dev environment or testing from phones and tablets on the same wifi. Do NOT use for production deployments, CI environments (set PORTLESS=0), or DNS/hosting configuration.4---5
6# Portless Integration
7
8Named `.localhost` URLs for local development. Replaces `localhost:3000` with `https://myapp.localhost`.
9
10> **Full CLI reference**: Load `Read("references/upstream.md")` for complete command docs.
11
12## New in 2026-04 → 2026-07 (portless 0.10.x → 0.15.0)
13
14- **`portless doctor` (0.15.0)** — read-only diagnostics that check Node.js, the state directory, proxy liveness, route entries, hostname resolution, HTTPS CA trust, and LAN prerequisites, then print suggested fixes. Run it before filing an issue or when a `.localhost` URL won't resolve.
15- **HTTP/2 Host forwarding fix (0.15.0)** — the proxy now forwards the HTTP/2 `:authority` as `Host` to HTTP/1.1 backends, fixing apps that read `Host` and previously saw `127.0.0.1` for browser traffic. `--force` takeover cleanup now removes only routes still owned by the exiting process, so a forced takeover no longer deregisters the new owner's route.
16- **`--ngrok` flag (0.14.0)** — share an app publicly via ngrok while local access keeps its `.localhost` URL. Pair with the existing Tailscale/Funnel options when you need a public URL without giving up the named-subdomain dev experience.
17- **Node.js 24+ required (0.13.1, BREAKING)** — the proxy and CLI now require Node.js 24 or newer; older runtimes are unsupported. This release also hardens startup-service persistence so `.localhost` URLs survive reboot reliably.
18- **State directory moved to `~/.portless` (0.11, BREAKING)** — state relocated from scattered/temp locations to `~/.portless`; override with `PORTLESS_STATE_DIR`. Old state from pre-0.11 installs is not migrated automatically.
19- **OS startup service (0.13.0)** — `portless service install` / `service status` / `service uninstall` register a native startup service for the HTTPS proxy across macOS launchd, Linux systemd, and Windows Task Scheduler. `.localhost` URLs survive reboot without a manual `portless proxy start`. `portless clean` removes the service alongside CA + hosts cleanup.
20- **Tailscale readiness preflight (0.13.0)** — `--tailscale` and `--funnel` now validate Tailscale HTTPS + Funnel prerequisites before starting the child process, surfacing actionable errors instead of hanging during registration.
21- **Tailscale integration (0.12.0)** — `--tailscale` shares your app over your tailnet with automatic HTTPS on port 443; `--funnel` exposes it publicly via Tailscale Funnel. Apps receive `PORTLESS_TAILSCALE_URL` so they can reference their own public address. `portless list` now shows tailnet URLs.
22- **Zero-config mode (0.11.0)** — bare `portless` auto-discovers dev scripts from `package.json`. Multi-app monorepos get automatic subdomain assignment; Turborepo task-graph integration is wired in. `portless.json` config file supported. `--script` overrides the default "dev" script.
23- **`portless prune`** — removes orphaned dev servers and stale Tailscale registrations.
24- **`portless clean` (extended)** — now also tears down Tailscale registrations alongside CA + hosts cleanup.
25- **Rsbuild + VitePlus auto-port injection** — same auto-wiring as Vite/Next.
26- **State directory** moved to `~/.portless` (was scattered).
27- **HTTPS on 443 by default** (breaking from 0.9.x http:1355). Valid cert, no setup. `--no-tls` reverts.
28- **`NODE_EXTRA_CA_CERTS` auto-injected (0.10.2)** into child processes — node HTTPS calls trust portless CA with zero setup.
29- **`--wildcard` subdomains** — `https://*.myapp.localhost` for multi-tenant / preview routing.
30- **`portless alias <name> <port>`** — map a docker-compose / emulate port to a named URL without a long-running `run` process.
31- **`portless clean`** — full teardown: stops proxy, removes CA, wipes state, cleans `/etc/hosts`.
32- **`--lan` mode** — mDNS `.local` hostnames reachable across wifi (phone, tablet, other machines) without router config.
33- **Fixed app ports** — `--app-port 3000` / `PORTLESS_APP_PORT` for tools that need a known port (debuggers, docker).
34- **hosts-sync on by default** for Safari compat (disable with `PORTLESS_SYNC_HOSTS=0`).
35- **HTTP/2 HMR fixes** for Vite/VitePlus/Next.js dev — websocket upgrades no longer break under h2.
36- **Expo / React Native** support — `portless run expo start` gives Metro a stable URL for device QR codes.
37
38## When to Use
39
40- Starting a dev server that agents or browser tests will target
41- Running multiple services locally (API + frontend + docs)
42- Working in git worktrees (branch-named subdomains)
43- Local OAuth flows (stable callback URLs)
44- Connecting emulate API mocks to named URLs
45
46## Quick Start
47
48```bash
49# Instead of: npm run dev (random port)
50portless run npm run dev
51# → https://myapp.localhost (stable, named, HTTPS on 443 — default in 0.10+)
52
53# Multi-service
54portless run --name api npm run dev:api
55portless run --name web npm run dev:web
56# → https://api.localhost, https://web.localhost
57
58# LAN mode (0.10.0) — reachable from phone/tablet via mDNS
59portless proxy start --lan
60portless run npm run dev
61# → https://myapp.local (resolves across the local network, no router config)
62
63# Full teardown (0.10.1) — stops proxy, removes CA, wipes state, cleans /etc/hosts
64portless clean
65
66# Boot persistence (0.13.0) — install native startup service (launchd / systemd / Task Scheduler)
67portless service install
68portless service status
69# Removed automatically by `portless clean`, or explicitly:
70portless service uninstall
71```
72
73> **0.10.x breaking change:** default switched from `https://app.localhost` to `https://app.localhost` on port 443. Use `--no-tls` to revert. `NODE_EXTRA_CA_CERTS` is injected into child processes automatically (0.10.2) — no manual cert setup. `/etc/hosts` is synced automatically for Safari; disable with `PORTLESS_SYNC_HOSTS=0`.
74
75## Framework-Specific Setup
76
77> Load `Read("references/framework-integration.md")` for full framework recipes.
78
79Most frameworks (Next.js, Vite, Express) work with `portless run <cmd>`. Some need explicit flags:
80
81| Framework | Auto-detected? | Extra flags needed |
82|-----------|:-:|---|
83| Next.js | Yes | None |
84| Vite / Astro | Yes | None |
85| Express / Fastify / Hono | Yes | None (reads `PORT` env var) |
86| Ruby on Rails | Yes | None |
87| FastAPI / uvicorn | **No** | `--port $PORT --host $HOST` |
88| Django | **No** | `$HOST:$PORT` positional arg |
89
90## Why `.localhost`?
91
92| Feature | `.localhost` (RFC 6761) | `127.0.0.1:PORT` | `/etc/hosts` hack |
93|---------|:-:|:-:|:-:|
94| No `/etc/hosts` editing | Yes | Yes | No |
95| HTTPS with valid cert | Yes | No | Manual |
96| Wildcard subdomains | Yes | No | No |
97| Works in all browsers | Yes | Yes | Varies |
98| Cookie isolation per service | Yes | No | Yes |
99| No port conflicts | Yes | No | Yes |
100
101## Key Environment Variables
102
103When portless runs your command, it injects:
104
105| Variable | Value | Use in agents |
106|----------|-------|---------------|
107| `PORT` | Assigned ephemeral port (4000-4999) | Internal only |
108| `HOST` | `127.0.0.1` | Internal only |
109| `PORTLESS_URL` | `https://myapp.localhost` | **Use this in agent prompts** |
110| `NODE_EXTRA_CA_CERTS` | Path to portless CA *(auto-injected 0.10.2)* | Child node processes trust portless certs without setup |
111
112### Toggle env vars
113
114| Variable | Effect |
115|----------|--------|
116| `PORTLESS=0` | Bypass portless entirely (CI) |
117| `PORTLESS_SYNC_HOSTS=0` | Disable auto `/etc/hosts` sync (default: on in 0.10.1+) |
118| `PORTLESS_STATE_DIR` | Override state dir (default: `~/.portless` or `/tmp/portless` for privileged ports) |
119
120## OrchestKit Integration Patterns
121
122### 1. Agent-Accessible Dev Server
123
124```bash
125# Start with portless, then agents can target PORTLESS_URL
126portless run npm run dev
127
128# In ork:expect or agent-browser:
129agent-browser open $PORTLESS_URL
130```
131
132### 2. Emulate + Portless (Named API Mocks)
133
134```bash
135# Register emulate ports as named aliases
136portless alias github-api 4001
137portless alias vercel-api 4000
138portless alias google-api 4002
139
140# Now agents can target:
141# https://github-api.localhost — GitHub emulator
142# https://vercel-api.localhost — Vercel emulator
143```
144
145### 3. Git Worktree Dev
146
147```bash
148# In worktree for feature/auth-flow:
149portless run npm run dev
150# → https://auth-flow.myapp.localhost (auto branch prefix)
151```
152
153### 4. Bypass in CI
154
155```bash
156# Disable portless in CI — direct port access
157PORTLESS=0 npm run dev
158```
159
160## Anti-Patterns
161
162| Don't | Do Instead |
163|-------|------------|
164| Hardcode `localhost:3000` in tests | Use `PORTLESS_URL` or `process.env.PORTLESS_URL` |
165| Run portless in CI | Set `PORTLESS=0` in CI environments |
166| Use numeric ports in AGENTS.md | Document the portless URL |
167
168## References
169
170| File | Content |
171|------|---------|
172| `references/upstream.md` | Full portless CLI reference (synced from Vercel) |
173| `references/upstream-oauth.md` | OAuth callback patterns with stable URLs |
174| `references/framework-integration.md` | Framework recipes (FastAPI, Django, Docker, gotchas) |
175| `checklists/new-project-setup.md` | Step-by-step: add portless to a new project |