Skip to main content

Overview

The proxy command controls the Portless proxy server lifecycle. The proxy runs as a background daemon and routes requests from .localhost URLs to your local dev servers.

Syntax

Subcommands

start

Start the proxy server in the background.
By default:
  • Listens on port 1355 (no sudo required)
  • Runs as a daemon (background process)
  • Logs to ~/.portless/proxy.log or /tmp/portless/proxy.log

stop

Stop the running proxy server.
Sends SIGTERM to the proxy process and cleans up state files.

Options

--port <number>, -p <number>

Specify the port for the proxy to listen on. Must be between 1 and 65535.
Ports below 1024 require sudo:

--https

Enable HTTP/2 with TLS using auto-generated certificates.
On first run:
  1. Generates a local CA certificate
  2. Attempts to add CA to system trust store
  3. Generates a wildcard certificate for *.localhost
Browsers will trust the certificates without warnings (after CA is trusted).

--cert <path>

Use a custom TLS certificate. Must be used with --key. Implies --https.
Certificate must be in PEM format starting with -----BEGIN CERTIFICATE-----.

--key <path>

Use a custom TLS private key. Must be used with --cert. Implies --https.
Key must be in PEM format starting with -----BEGIN PRIVATE KEY----- or similar.

--no-tls

Disable HTTPS even if PORTLESS_HTTPS environment variable is set.

--foreground

Run the proxy in the foreground instead of as a daemon. Useful for debugging.
Logs are printed to stdout/stderr instead of a log file.

Examples

Basic Start

Output:

Start with HTTPS

Output:

Start on Port 80 (Requires Sudo)

Output:
Now your apps are accessible at http://myapp.localhost (no port in URL).

Start on Port 443 with HTTPS (Requires Sudo)

Output:
Now your apps are accessible at https://myapp.localhost (standard HTTPS port).

Use Custom Certificates

Stop the Proxy

Output:

Debug Mode (Foreground)

Output:
Press Ctrl+C to stop.

Auto-Start

The proxy auto-starts when you run an app with portless run or portless <name>:
If the proxy is not running:
  • Port < 1024: Prompts for sudo permission
  • Port >= 1024: Starts silently without sudo
You can skip auto-start by responding skip when prompted.

State Directory

The proxy stores state in a directory that depends on the port:
  • Port < 1024 (privileged): /tmp/portless
  • Port >= 1024 (unprivileged): ~/.portless
Override with PORTLESS_STATE_DIR environment variable. State files:
  • proxy.pid - Process ID of the running proxy
  • proxy.port - Port the proxy is listening on
  • proxy.tls - Marker file (exists if HTTPS is enabled)
  • proxy.log - Proxy logs (daemon mode only)
  • routes.json - Active routes
  • ca.pem, ca-key.pem - Local CA (if using —https)
  • cert.pem, key.pem - Wildcard certificate (if using —https)

Errors

Port Already in Use

Output:
Solution: Stop the proxy or use a different port.

Permission Denied (Privileged Port)

Output:
Solution: Run with sudo.

Already Running

Output:
Solution: Stop first, then start.

Invalid Certificate

Output:
Solution: Use a valid PEM certificate.

Missing —cert or —key

Output:
Solution: Provide both flags.

HTTP/2 Benefits

Enabling HTTPS with --https enables HTTP/2, which provides:
  • Connection multiplexing - All requests over a single connection
  • Faster page loads - Eliminates HTTP/1.1’s 6-connection limit
  • Better for dev servers - Vite, Nuxt, and other unbundled servers benefit most
HTTP/2 requires TLS, so you must use --https or provide custom certificates.

Exit Codes

  • 0 - Success
  • 1 - Error (port in use, permission denied, invalid arguments, failed to start)