curl, a browser, a database driver, an existing library that only knows how to dial a socket. forward() publishes the tunnel on a local address so all of them just work.
Prerequisites
- An API key from the console, exported as
BOXLITE_API_KEY. See API keys. pip install boxlite, and the REST URL exported asBOXLITE_REST_URL. See Quickstart.- A box you can start, and a service inside it that listens on a TCP port.
forward() publishes the tunnel on an address on your machine, so any TCP client — curl, a browser, a database driver, an existing library that only knows how to dial a socket — can reach the service without knowing about BoxLite.
- The host must be a numeric IP.
SocketAddress.tcp(host="localhost")raisesValueError: tunnel listener host must be a numeric IP— pass"127.0.0.1". port=0is the default and asks the operating system for a free port. Read the port you actually got fromforwarder.local_addr().port.- A Unix socket path must be absolute.
SocketAddress.unix("relative.sock")raisesValueError: tunnel Unix socket path must be absolute.
await forwarder.wait() blocks until the forwarder finishes, which is what you await in a long-running process instead of exiting. await forwarder.close() shuts it down. The forwarder is built from a tunnel, and forward() spends that tunnel, so build each forwarder from its own fresh await box.network.tunnel(port).
Next steps
Network
How tunnels work, the full parameter reference, and the outbound boundary.
Network policy
Control what the box itself is allowed to reach.

