Skip to main content
Portless supports several environment variables to customize its behavior. These can be set in your shell configuration files (.bashrc, .zshrc, etc.) or exported in your terminal session.

Proxy Configuration

number
default:"1355"
Override the default proxy port. The proxy will listen on this port instead of the default 1355.Ports below 1024 require sudo to bind. Portless automatically selects the appropriate state directory based on the port number:
  • Ports < 1024: Uses /tmp/portless (system-wide, shared between root and non-root processes)
  • Ports >= 1024: Uses ~/.portless (user-specific)
string
default:""
Enable HTTPS/HTTP2 mode by default. Set to 1 or true to always start the proxy with TLS enabled.When enabled, Portless generates a local Certificate Authority (CA) and uses it to issue certificates for your .localhost domains. The CA is automatically added to your system trust store on first use.
You can override this with the --no-tls flag when starting the proxy.
string
default:"auto"
Override the state directory location. By default, Portless automatically selects the state directory based on the proxy port:
  • Ports < 1024: /tmp/portless
  • Ports >= 1024: ~/.portless
Setting this variable forces Portless to use a specific directory regardless of the port number.
See State Directory for more details on state directory structure and behavior.

Application Configuration

number
default:"auto"
Use a fixed port for your application instead of automatically assigning one from the 4000-4999 range.Equivalent to the --app-port CLI flag. Useful when your application has specific port requirements or when you need to configure another service to connect to a known port.
string
default:""
Automatically sync /etc/hosts whenever routes change. Set to 1 to enable.This is useful for Safari, which relies on the system DNS resolver and may not resolve .localhost subdomains automatically. When enabled, Portless adds entries to /etc/hosts for each registered route.Important: The proxy must be started with sudo for this to work, as modifying /etc/hosts requires root permissions.
See Safari DNS Issues for more details.
string
default:""
Skip Portless entirely and run commands directly. Set to 0 or skip to bypass the proxy.This is useful when you temporarily need to run your application without Portless, or when debugging connection issues.

Child Process Environment

When Portless runs your application, it sets the following environment variables in the child process:
string
The port your application should listen on. This is either an automatically assigned port from the 4000-4999 range, or the value of PORTLESS_APP_PORT if set.Most web frameworks respect this variable. For frameworks that don’t (Vite, Astro, React Router, Angular, Expo, React Native), Portless automatically injects --port and --host flags.
string
default:"127.0.0.1"
The host your application should bind to. Always set to 127.0.0.1 to ensure the proxy can connect to your app.This prevents frameworks from binding to IPv6 ::1 instead of IPv4, which would make them unreachable by the proxy.
string
The public URL of your application (e.g., http://myapp.localhost:1355 or https://myapp.localhost:1355).Use this when your application needs to construct URLs pointing to itself, such as for OAuth callbacks or webhooks.
string
default:".localhost"
Internal variable set for Vite to allow .localhost subdomains. This prevents Vite from blocking requests from the proxy.

Examples

Development Environment Setup

~/.zshrc or ~/.bashrc

Team-Shared Configuration

.envrc (with direnv)

Debugging Without Portless