Skip to content

bhatti forward

Connect TCP listeners on the machine running the CLI to guest ports, without a public domain or guest NIC.

Synopsis

bhatti forward <sandbox> <port-spec>... [--address <address>]

Description

Each port specification is PORT (the same local and guest port) or LOCAL:GUEST. Use 0:GUEST to pick a free local port. The CLI binds all listeners on the machine running the CLI, using 127.0.0.1 by default; --address changes that address. All requested local ports must be available before forwarding starts.

Each local TCP connection gets an authenticated WebSocket tunnel through the API, then a vsock connection to the guest port. A remote CLI therefore forwards to your laptop, not the server's loopback. No guest NIC is required.

The CLI stays running until Ctrl-C/SIGTERM, which closes its listeners and active connections. --json prints an array of mappings (sandbox, local_addr, local_port, guest_port) after binding and continues forwarding; it does not return an API response and exit. For public HTTP routes, use publish with a configured public proxy.

Examples

bhatti forward dev 3000
# Forwarding 127.0.0.1:3000 -> dev:3000  (Ctrl-C to stop)

bhatti forward dev 15432:5432
# Connect from the CLI machine to 127.0.0.1:15432

bhatti forward dev 3000 15432:5432
# Forward two different local ports in one process

bhatti forward dev 0:5432 --json
# Print the assigned local port, then keep forwarding

Options

| Flag | Default | Description | | --- | --- | --- | | --address <address> | 127.0.0.1 | Local listen address. 0.0.0.0 exposes the forwarded ports on all IPv4 interfaces; use it only when intended. |

See Global flags for --url, --token, --json, --timing, --data-dir.

See also