Skip to main content

Overview

Portless can be configured using environment variables. These are useful for setting defaults in your shell config (.bashrc, .zshrc) or for per-project configuration.

Configuration Variables

These variables configure Portless behavior:

PORTLESS_PORT

Override the default proxy port (1355).
Valid values: 1-65535
Default: 1355
Overridden by: --port / -p flag

PORTLESS_APP_PORT

Use a fixed port for apps instead of automatic assignment (4000-4999 range).
Valid values: 1-65535
Default: Auto-assigned in 4000-4999 range
Overridden by: --app-port flag

PORTLESS_HTTPS

Always enable HTTPS when starting the proxy.
Valid values: 1, true
Default: Not set (HTTP)
Overridden by: --no-tls flag

PORTLESS_SYNC_HOSTS

Automatically sync /etc/hosts whenever routes change. Requires proxy to be started with sudo.
Valid values: 1
Default: Not set (manual sync only)
Requires: Proxy started with sudo

PORTLESS_STATE_DIR

Override the state directory location.
Default:
  • Port < 1024 (privileged): /tmp/portless
  • Port >= 1024 (unprivileged): ~/.portless

PORTLESS

Skip the proxy and run commands directly.
Valid values: 0, skip
Default: Not set (uses proxy)

Injected Variables

These variables are injected into your app’s process by Portless:

PORT

The port your app should listen on.
Most frameworks (Next.js, Express, Nuxt, etc.) respect this automatically.

HOST

The host your app should bind to. Always set to 127.0.0.1.
Prevents frameworks from binding to IPv6 ::1.

PORTLESS_URL

The public URL of your app.
Use this to:
  • Generate absolute URLs in your app
  • Configure OAuth redirect URIs
  • Reference your app from other services

__VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS

Set to .localhost for Vite compatibility.
Prevents Vite from rejecting requests with .localhost host headers.

Examples

Permanent HTTPS Setup

Add to .bashrc or .zshrc:
Now every time you start the proxy, it uses HTTPS:

Custom Port for Development

Auto-Sync Hosts for Safari

Add to shell config:
Start proxy with sudo:
Now /etc/hosts updates automatically when routes change.

Fixed App Port

Custom State Directory

Skip Proxy Temporarily

Use in Scripts

package.json:
Makefile:

Environment Priority

When multiple configuration sources exist, priority is:
  1. CLI flags (highest priority)
  2. Environment variables
  3. Defaults (lowest priority)
Examples:

Validation

Invalid Port

Invalid App Port

Debugging

To see which port Portless is using:

See Also