# Register a static routeportless alias myapp 3000# -> http://myapp.localhost:1355 routes to :3000# Your service must already be listening on port 3000# (or start it separately)
# Register a static routeportless alias <name> <port># Overwrite an existing routeportless alias <name> <port> --force# Remove a static route portless alias --remove <name># List all routes (including static ones)portless list
# Start multiple containersdocker run -d -p 5432:5432 --name postgres postgres:16docker run -d -p 6379:6379 --name redis redis:7docker run -d -p 9200:9200 --name elasticsearch elasticsearch:8.11.0# Register all with portlessportless alias db 5432portless alias cache 6379portless alias search 9200# Access:# http://db.localhost:1355# http://cache.localhost:1355# http://search.localhost:1355
If you have a server already running that doesn’t use the PORT environment variable:
# Server is hardcoded to listen on :4000ruby server.rb &# Register it with portlessportless alias rails-app 4000# Access at http://rails-app.localhost:1355
By default, portless alias fails if a route is already registered:
# First registration succeedsportless alias api 3000# Second failsportless alias api 4000# Error: "api" is already registered by a running process (PID 12345).# Use --force to override.
Use --force to overwrite:
portless alias api 4000 --force# Overwrites the existing route
Using --force will disconnect any active connections to the old route. The new route takes effect immediately.
You can mix static routes with dynamic portless run routes:
# Static route for databaseportless alias db 5432# Dynamic route for API (portless manages lifecycle)portless api node server.js# Dynamic route for frontendportless web next dev# All accessible via portless:# http://db.localhost:1355 -> :5432 (static)# http://api.localhost:1355 -> :4123 (dynamic, random port)# http://web.localhost:1355 -> :4567 (dynamic, random port)
Static routes support wildcard routing just like dynamic routes:
# Register a static routeportless alias app 8080# All these work automatically:# http://app.localhost:1355 -> :8080# http://tenant1.app.localhost:1355 -> :8080# http://tenant2.app.localhost:1355 -> :8080
Your service receives the full Host header and can route internally based on the subdomain.
# docker-compose.yml starts databasesdocker compose up -d# Register databasesportless alias postgres 5432portless alias redis 6379# Run application services through portlessportless api npm run dev:apiportless web npm run dev:web# Access:# http://postgres.localhost:1355 (Docker)# http://redis.localhost:1355 (Docker)# http://api.localhost:1355 (portless-managed)# http://web.localhost:1355 (portless-managed)
{ "scripts": { "dev:api": "portless alias api 3001 && npm run start:api", "dev:web": "portless run next dev", "dev:admin": "portless run vite", "dev:all": "pnpm -r --parallel run dev" }}
# Check active routesportless list# Remove the conflicting routeportless alias --remove api# Or use --force to overwriteportless alias api 4000 --force
If you register a static route but later stop the service without removing the route, the route remains registered. Requests will fail with “connection refused”.Clean up manually: