Skip to main content

Overview

The alias 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 in docker-compose.yml with port mappings:
Register them with Portless:
Now your app can connect to 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

Listing Aliases

Aliases appear in portless list with (alias) label:
Output:

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)