Client

HTTP Tunnel

Learn how to start an HTTP tunnel with the Portr CLI to expose a local web server or API to the public internet in a single command.

Use the following command to tunnel an HTTP connection.

portr http 9000

Or start it with a custom subdomain:

portr http 9000 --subdomain amal-test

This also starts the portr inspector on http://localhost:7777 by default, where you can inspect and replay HTTP requests. Change dashboard_port in the client config to move it to another local port, or set disable_dashboard: true to skip starting it entirely.

Rewriting the Host header

By default, Portr forwards the public host (amal-test.portr.dev) to your local server. Frameworks with host allowlists — Rails host authorization, Django ALLOWED_HOSTS, Vite server.allowedHosts — reject those requests.

portr http 9000 --host-header rewrite

rewrite replaces the Host header with the local address (localhost:9000). Any other value is sent literally, which is useful for vhost-based local setups:

portr http 9000 --host-header myapp.local

Or per tunnel in the config file:

tunnels:
  - name: rails
    subdomain: rails
    port: 3000
    host_header: rewrite

rewrite changes the hostname your app believes it is served from, so absolute URLs and redirects it generates will point at the local address. If that matters, leave host_header unset and add the public host to your framework's allowlist instead.

host_header is only valid on type: http tunnels. The inspector always records the original public host, not the rewritten one.

How it works

When you run the HTTP tunnel command:

  1. Portr connects to your configured server
  2. Creates a secure tunnel from your local port to a public URL
  3. Starts the request inspector interface locally
  4. Routes all incoming requests through the tunnel to your local service

Inspector Features

The Portr inspector provides powerful debugging capabilities:

  • Request inspection: View all incoming HTTP requests in real-time
  • Request replay: Replay a stored request as-is or edit it before resending
  • Headers analysis: Examine request and response headers
  • Payload viewing: Inspect request and response bodies
  • WebSocket inspection: Monitor upgraded WebSocket sessions and captured frames

Common Use Cases

  • Local web development: Share your local development server with others
  • Webhook testing: Receive webhooks from external services during development
  • API debugging: Test API integrations with external services
  • Demo presentations: Show your work to clients or team members