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).
Default: 1355
Overridden by:
--port / -p flag
PORTLESS_APP_PORT
Use a fixed port for apps instead of automatic assignment (4000-4999 range).
Default: Auto-assigned in 4000-4999 range
Overridden by:
--app-port flag
PORTLESS_HTTPS
Always enable HTTPS when starting the proxy.
1, trueDefault: 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.
1Default: Not set (manual sync only)
Requires: Proxy started with sudo
PORTLESS_STATE_DIR
Override the state directory location.
- Port < 1024 (privileged):
/tmp/portless - Port >= 1024 (unprivileged):
~/.portless
PORTLESS
Skip the proxy and run commands directly.
0, skipDefault: 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.
HOST
The host your app should bind to. Always set to 127.0.0.1.
::1.
PORTLESS_URL
The public URL of your app.
- 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.
.localhost host headers.
Examples
Permanent HTTPS Setup
Add to.bashrc or .zshrc:
Custom Port for Development
Auto-Sync Hosts for Safari
Add to shell config:/etc/hosts updates automatically when routes change.
Fixed App Port
Custom State Directory
Skip Proxy Temporarily
Use in Scripts
package.json:Environment Priority
When multiple configuration sources exist, priority is:- CLI flags (highest priority)
- Environment variables
- Defaults (lowest priority)
Validation
Invalid Port
Invalid App Port
Debugging
To see which port Portless is using:See Also
- CLI Flags - Override environment variables with flags
- portless proxy - Proxy server configuration
- portless run - Run apps with environment configuration