TCP Tunnels

TCP Tunnels

Publish raw TCP services through ephemeral or reserved addresses.


A published TCP tunnel exposes a public hostname and port and relays each accepted connection to a TCP service behind the rstream agent. It is intended for protocols such as SSH that already provide their own encryption and authentication.

rstream does not secure the downstream side of a TCP tunnel. The bytes received on the public port are forwarded as-is. Use a secure application protocol, and use a TLS tunnel when rstream should terminate TLS or pass a TLS session through to the upstream service.

Published TCP tunnels are available on Pro and Enterprise projects. They are enabled by default, and the project must allow public access.

Ephemeral addresses

Use --tcp to publish a local TCP service on an address allocated for the lifetime of the tunnel:

rstream forward 22 --tcp

The command prints the allocated address as a hostname and port. A client connects directly to that address. For SSH, for example:

ssh -p <port> <user>@<tcp-hostname>

The port returns to the ephemeral pool when the tunnel closes. Do not build a persistent client configuration around an ephemeral address.

Reserved addresses

A current workspace owner or admin can reserve and release addresses using personal access or an authorized App with account.projects.read-write. Reading reservations requires account.projects.read-only. Workspace Tokens can publish tunnels on an existing reservation, but cannot manage reservations through the Control plane API.

A reserved TCP address belongs to a project independently of a running tunnel. Reserve one from the project TCP page in the dashboard or from the CLI:

rstream project tcp-address reserve

The result contains an address and its public port. Pass the port when opening the tunnel:

rstream forward 22 --tcp --tcp-port <port>

The engine verifies that the port is reserved by the authenticated project before opening the listener. A reservation can be used by only one live tunnel at a time.

List the project addresses with:

rstream project tcp-address list

The dashboard also correlates each reservation with its live tunnel. This association is runtime state: the reservation remains available while the agent is offline.

Stop a tunnel before releasing its address. The dashboard disables release while its live project Watch reports an active binding. The CLI uses the public port:

rstream project tcp-address release <port>

The address leaves the project immediately and enters quarantine before it can be assigned again. Reachable engines remove an active binding immediately. A bounded authorization lease lets a private or temporarily unreachable engine detect a missed release when the next connection arrives. Quarantine prevents a newly assigned project from receiving connections that were still intended for the previous owner.

Edge routing

A regional project receives published TCP connections in its selected region. A Global project can receive them through another edge region while the agent control channel remains attached to its owner region. Direct routing asks the agent to connect to the ingress that accepted the downstream connection, keeping the payload off an additional inter-region hop.

Cross-region routing may be allowed for a tunnel with --allow-cross-region-routing. This gives the edge permission to carry the stream between regions when the owner and ingress differ; it does not force that path. Same-region traffic always remains Direct, and a failed Cross-region setup falls back to Direct when that path is available.

Connection logs record the path used and identify the ingress and owner regions. See Global and Regional Routing for the protocol-independent routing model.

Project security policy

Published TCP is enabled by default. A project owner or administrator can disable Published TCP tunnels in the project settings when the project must never expose raw TCP services. The project public access policy must be allowed.

auth-required is deliberately incompatible with raw TCP publishing. Token authentication, rstream Auth, and Tunnel mTLS depend on a protocol handshake at the edge; a raw TCP listener has no such handshake. Authentication must therefore be provided by the application protocol itself. forbidden rejects the tunnel like every other published tunnel.

Declarative configuration

YAML uses protocol: tcp. Omit port for an ephemeral address, or set it to the port of an existing reservation:

version: 1
tunnels:
  - name: ssh
    forward: 22
    tunnel:
      publish: true
      protocol: tcp
      port: 10042

The corresponding Docker labels are:

labels:
  rstream.tunnel.ssh.forward: "22"
  rstream.tunnel.ssh.publish: "true"
  rstream.tunnel.ssh.protocol: "tcp"
  rstream.tunnel.ssh.port: "10042"

In Kubernetes, use spec.protocol: tcp and the optional spec.tcpPort field. The operator rejects TCP manifests that request a hostname, a datagram tunnel, a private tunnel, or HTTP and TLS options.

Self-hosted engines

Community Edition supports ephemeral TCP addresses. For listener backends, port ranges and host networking, see Published TCP networking. Reserved addresses require the hosted Control plane.