Overview
Theportless run command automatically infers your project name from your codebase and runs your dev server through the Portless proxy. This is the recommended way to use Portless since it requires no manual configuration.
Syntax
Name Inference
Portless infers the project name automatically by checking these sources in order:- package.json - Walks up directories looking for a
namefield - Git repo - Uses the root directory name of the repository
- Current directory - Uses the basename of the current working directory
Git Worktree Support
When you’re in a git worktree,portless run automatically prepends the branch name as a subdomain prefix:
- Main worktree (main/master branch) - No prefix, uses plain project name
- Linked worktree (e.g.
fix-uibranch) - Branch name becomes prefix:fix-ui.<project>.localhost - Branch with slashes (e.g.
feature/auth) - Uses last segment:auth.<project>.localhost
portless run to your package.json once and it works everywhere without conflicts.
Options
--force
Override an existing route registered by another process.
--app-port <number>
Use a fixed port for the app instead of automatic port assignment. Must be between 1 and 65535.
--help, -h
Show help for the run command.
--
Stop flag parsing. Everything after -- is passed directly to your command.
Examples
Basic Usage
With package.json
pnpm dev will start your app at http://myapp.localhost:1355.
In Git Worktrees
Fixed Port
Override Route
Environment Variables
The following environment variables are injected into your command:PORT- Ephemeral port the app should listen on (e.g. 4123)HOST- Always set to127.0.0.1PORTLESS_URL- Public URL of your app (e.g.http://myapp.localhost:1355)__VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS- Set to.localhostfor Vite compatibility
Proxy Auto-Start
If the proxy is not running,portless run will automatically start it:
- Privileged port (< 1024): Prompts for sudo permission
- Non-privileged port (default 1355): Starts silently without sudo
skip when prompted.
Skip Portless
To run your command directly without the proxy:Framework Support
Most frameworks respect thePORT environment variable. For frameworks that don’t (Vite, Astro, React Router, Angular, Expo, React Native), Portless automatically injects the correct --port and --host flags.
Exit Codes
- 0 - Success
- 1 - Error (no command provided, route conflict, proxy start failure)
- Exit code of child process - Propagated from your dev server