Client

TCP Tunnel

Learn how to start a TCP tunnel with the Portr CLI to expose local databases, SSH, and other raw TCP services to the public internet.

Use the following command to tunnel a TCP connection:

portr tcp 9000

To expose a service on another reachable machine, pass host:port instead of a bare port:

portr tcp 192.168.1.60:5432

TCP tunnels are useful for exposing services like databases, SSH servers, or any service that uses raw TCP connections.

How it works

TCP tunnels work differently from HTTP tunnels:

  1. Portr establishes a direct TCP connection between the remote client and your local service
  2. No HTTP processing is involved - raw TCP data is forwarded
  3. The connection is bidirectional and maintains the TCP session state

Common Use Cases

  • Database access: Connect to local databases from remote applications
  • SSH tunneling: Access local SSH servers from remote locations
  • Custom protocols: Tunnel any service that uses TCP connections
  • Legacy applications: Connect to services that don't use HTTP

Port Requirements

Your Portr server needs to have the port range 30001-40001 open to accept incoming TCP connections. Make sure your server administrator has configured these ports.

Configuration

TCP tunnels do not use subdomains — the server assigns a public port from the 30001-40001 range and prints the address when the tunnel starts. Define one in the config file like any other tunnel:

tunnels:
  - name: postgres
    type: tcp
    port: 5432