Overview
Thealias command registers static routes for services not managed by Portless, such as Docker containers, databases, or external servers. Unlike routes created by portless run or portless <name>, aliases are not tied to a process and persist until explicitly removed.
Syntax
Parameters
<name>
The hostname for the service. Can include subdomains separated by dots.
<port>
The local port where the service is listening. Must be between 1 and 65535.
Options
--force
Override an existing route with the same name.
--remove
Remove an existing alias.
--help, -h
Show help for the alias command.
Examples
Docker Services
External APIs
With Subdomains
Override Existing Route
Remove Aliases
Use Cases
Docker Compose
If you have services defined indocker-compose.yml with port mappings:
http://postgres.localhost:1355 and http://redis.localhost:1355.
Static Mock Server
Run a mock API server separately, then alias it:Microservices in Monorepo
If you have services that run independently but need stable URLs:Aliases vs Regular Routes
| Feature | Regular Route (portless <name>) | Alias (portless alias) |
|---|---|---|
| Process tracking | Yes (PID stored) | No (PID is 0) |
| Auto-cleanup | Yes (when process exits) | No (persists until removed) |
| Port assignment | Automatic (4000-4999) | Manual (you specify) |
| Use case | Dev servers | Docker, databases, static services |
Listing Aliases
Aliases appear inportless list with (alias) label:
Errors
Missing Arguments
Invalid Port
Alias Not Found
Route Conflict
If a route already exists (either from another process or another alias), use--force:
Exit Codes
- 0 - Success
- 1 - Error (invalid arguments, alias not found, route conflict without —force)