# TCP tunnels

Source: https://prontaro.com/docs/tunnels/tcp/

Reach local PostgreSQL, SSH, Redis, MQTT, or custom TCP services behind NAT without a VPN or router port forwarding — connecting clients need no extra software.

Prontaro forwards TCP traffic directly without decryption, preserving end-to-end TLS and SSH encryption. TCP tunnels are available starting on the Tunnels plan (a persistent port on a shared IP) and also on your dedicated static IPv4 on Dedicated and Pro.

## Inbound `prontaro tcp` and outbound `prontaro forward`

Both commands forward TCP traffic in opposite directions:

| Property | `prontaro tcp` (inbound) | `prontaro forward` (outbound) |
| --- | --- | --- |
| Direction | External client → your service | Your app → remote host via your IP |
| Who opens the connection | External client to Prontaro | Local app to `127.0.0.1:<port>` |
| Minimum plan | Tunnels / Dedicated (own IP) | Dedicated or Pro |
| Use case | Expose local Postgres or SSH | Reach a remote DB from your static IP |

```text
Inbound (prontaro tcp 5432 --to 203.0.113.10):
  Remote client ──▶ Prontaro Edge (IP filter) ──▶ prontaro CLI ──▶ 127.0.0.1:5432

Outbound (prontaro forward 15432 db.example.com:5432):
  Local app ──▶ 127.0.0.1:15432 ──▶ prontaro CLI ──▶ 203.0.113.10 ──▶ db.example.com:5432
```

If your app needs to connect out to a remote database or API from your static IP, use [`prontaro forward`](https://prontaro.com/docs/outbound/forward.md).

## How it works

`prontaro tcp` maintains an outbound TLS connection to a Prontaro edge node. When an allowed client connects to your public port, the edge forwards TCP traffic straight to your local service.

### Shared and dedicated IP ports

| Entry point | `--to` flag | Behavior |
| --- | --- | --- |
| Shared Prontaro address | `--to shared` or `--to shared@<IP>` | Starts on Tunnels. Assigns a persistent port (e.g. `<entry>.tcp.prontaro.run:41283`). Re-open a tunnel on a specific shared port anytime with `--to <entry>.tcp.prontaro.run:41283`. |
| Dedicated IP `:port` | `--to <your-IP>` or `--to <your-IP>:15432` | Available on Dedicated and Pro. External port defaults to the local port; pass `:port` to map another. Up to 100 ports per IP. |

Port `443` on a dedicated IP serves either a TCP tunnel or own-IP HTTPS tunnels, never both. A stopped tunnel still holds port `443`, so `prontaro stop` does not free it: remove it with `prontaro rm` (or move HTTPS tunnels to `--to shared@<your-IP>`).

### Real client IPs with `--proxy-protocol`

Without PROXY protocol, your local server sees every tunneled connection as coming from `127.0.0.1`. Pass `--proxy-protocol v1` or `--proxy-protocol v2` to prepend an HAProxy PROXY protocol header with the real client IPv4 and port:

- `v1` — human-readable ASCII header (`PROXY TCP4 198.51.100.7 203.0.113.10 51822 5432\r\n`), handy for debugging.
- `v2` — compact binary header, preferred in production for nginx `stream` (`listen 5432 proxy_protocol;`), HAProxy (`accept-proxy`), Envoy, and Postfix.

> **Only enable --proxy-protocol for servers that expect it**
>
> Stock `sshd` or PostgreSQL without a PROXY-aware frontend will drop the connection because they don’t speak PROXY protocol.

### Closed by default

Every new TCP tunnel starts closed to everyone—packets from unlisted IPs are dropped by the edge kernel filter before a TCP connection is established.

In an interactive terminal, `prontaro` prompts immediately to allow your current IP, enter specific addresses, open to everyone, or keep it closed. In scripts and services, manage access with [`prontaro access`](https://prontaro.com/docs/tunnels/access.md) or in the dashboard.

## Quick setup

You can create a TCP tunnel and configure its IP allowlist in either the CLI or the dashboard. The tunnel process itself always runs on your machine via `prontaro CLI` (`prontaro tcp` or `prontaro run`).

#### In the dashboard

1. Open **Tunnels** and click **Create tunnel** → **TCP**.
2. Choose a shared port or your dedicated IP and external port, enter the local address (e.g. `127.0.0.1:5432`), and add allowed IPv4/CIDR entries right away.
3. Start the tunnel on your machine—`prontaro` picks up the saved configuration:

```bash
prontaro run pg-prod
```

From the tunnel page in the dashboard, you can monitor status, active connections, logs, and access rules, or stop and delete the tunnel.

Tunnels [Open in dashboard](https://my.prontaro.com/tunnels)

#### In the terminal (CLI)

Expose local PostgreSQL on port `5432` of your dedicated IPv4:

**Start a TCP tunnel on your dedicated IP**

```bash
prontaro tcp 5432 --name pg-prod --to 203.0.113.10
```

**Interactive access prompt and live screen**

```text
? Port 203.0.113.10:5432 is closed to everyone. Who should reach it?
  › only the address API sees for you: 198.51.100.7
    enter addresses…
    everyone
    nobody for now

prontaro 0.2.0                                          Ctrl+C to stop

  Tunnel     pg-prod                                 ● connected
  Address    203.0.113.10:5432  →  127.0.0.1:5432
  Access     1 address   (as of launch)
  Server     <server> · <region> · 18 ms
  Account    user@example.com
  Slots      2 of 25 · plan "Dedicated"   (as of launch)

  Connections  total 0 · open 0
```

`prontaro tcp` runs in your active terminal window until you press `Ctrl+C`. To update rules from the CLI while it runs, run `prontaro access` in a second terminal (or use the dashboard).

**Terminal 1: start a TCP tunnel with PROXY protocol v2**

```bash
prontaro tcp 127.0.0.1:8443 --name edge-tls --to 203.0.113.10:443 --proxy-protocol v2
```

**Terminal 2: allow a CIDR subnet**

```bash
prontaro access edge-tls allow 198.51.100.0/24
```

**Access confirmation**

```text
✓ edge-tls now open only to 198.51.100.0/24 (was: closed); takes effect within seconds.
```

## Limits and notes

- **No HTTPS request quota.** TCP tunnels keep working even when HTTPS requests hit `100%`.
- **Bidirectional traffic.** Both inbound and outbound bytes count toward your monthly traffic allowance. See [Usage, limits & quotas](https://prontaro.com/docs/billing/limits.md).
- **Concurrent connections.** Counted per dedicated IP or across the shared Prontaro address (separately from outbound proxy connections): Tunnels — 200, Dedicated — 300, Pro — 1,000.
- **TCP only (no UDP).** UDP protocols (UDP DNS, QUIC, WireGuard) are not supported.
- **Ports.** Up to 100 TCP ports per dedicated IP; shared ports are assigned automatically.
- **Moving to another address.** Shared and dedicated-IP TCP tunnels are separate tunnel types and cannot be moved directly. Create a new TCP tunnel on the desired address, update clients, and remove the old one with `prontaro rm`.

## FAQ

### Connections time out while `prontaro tcp` is running

Check rules with `prontaro access <tunnel>` or on the **Access** tab in the dashboard: new TCP tunnels start closed. Allow your address with `prontaro access <tunnel> allow 198.51.100.7` (replace with your public IPv4) or pass a CIDR subnet.

### Connections open and immediately close

Either nothing is listening locally (`Nothing is listening on 127.0.0.1:5432 yet`), or `--proxy-protocol` is enabled while your local service doesn’t speak PROXY protocol.

### Can I expose a service on another LAN host?

Yes. Pass `host:port` as the local address, such as `prontaro tcp 10.0.0.15:22 --name lan-ssh --to 203.0.113.10:2222`. URL schemes (`http://`, `tcp://`) are not accepted by `prontaro tcp`.

## Next steps

- [Access control & firewalls](https://prontaro.com/docs/tunnels/access.md) — configure IP allowlists and port firewalling for TCP tunnels.
- [Local port forwarding (prontaro forward)](https://prontaro.com/docs/outbound/forward.md) — route outbound TCP connections from your dedicated static IP.
- [Background services (Linux & macOS)](https://prontaro.com/docs/cli/service.md) — keep tunnels running in the background without an open terminal.
- [SSH, SFTP, and databases behind NAT](https://prontaro.com/docs/tunnels/ssh-and-db.md) — step-by-step guides for inbound and outbound SSH, SFTP, and database access.
- [Usage, limits & quotas](https://prontaro.com/docs/billing/limits.md) — concurrency caps and monthly traffic allowances by plan.
