# Local port forwarding (prontaro forward)

Source: https://prontaro.com/docs/outbound/forward/

Any database driver, SFTP client, or CLI binary that lacks proxy support can still reach remote servers from your dedicated static IPv4 through a local TCP port.

`prontaro forward` listens on `127.0.0.1` and relays every connection to a remote `host:port` from your fixed IP without decrypting TLS, SSH, or database protocols. Your client connects to `127.0.0.1:<port>` as if the service were local.

> **Outbound, not inbound**
>
> `prontaro forward` is outbound — your local machine dials a remote server through your Prontaro IP. To accept inbound TCP connections from the internet onto your machine, use [`prontaro tcp`](https://prontaro.com/docs/tunnels/tcp.md) instead.

## Prerequisites

- A Dedicated or Pro plan with an IP added under [IP addresses](https://my.prontaro.com/ips).
- `prontaro CLI` installed and signed in (`prontaro login`), or `PRONTARO_KEY` set in your container or CI environment.

## Quick start

Forward local port `15432` to an allowlisted PostgreSQL server at `db.example.com:5432` (omit `--ip` if you have only one static IP):

```bash
prontaro forward 15432 db.example.com:5432 --ip 203.0.113.10
```

```text
prontaro forward 15432 db.example.com:5432
  127.0.0.1:15432  →  db.example.com:5432 from your IP 203.0.113.10
```

In another terminal, connect with `psql` to `127.0.0.1:15432`:

```bash
psql "postgresql://app@127.0.0.1:15432/prod?sslmode=require"
```

> **Strict TLS hostname verification (verify-full)**
>
> When your client dials `127.0.0.1:15432`, the remote server still presents a TLS certificate for `db.example.com`, not `127.0.0.1`. Cloud databases such as MongoDB Atlas and RDS often enable strict hostname checking by default.
>
> If your driver rejects the certificate for a hostname mismatch, configure the expected TLS server name (SNI) in the driver — or map `db.example.com → 127.0.0.1` in `/etc/hosts` when keeping the same port.

### Containers, sidecars, and scripts

- Authenticate with the `PRONTARO_KEY` environment variable.
- Pass `--no-input` to disable prompts and `--json` for structured logs on `stderr`.
- On a startup refusal, `forward` exits right away with a non-zero code, so run the container under a restart policy (`docker run --restart unless-stopped` or `restart: unless-stopped` in Compose).
- When `forward` runs as a sidecar container for neighboring services, pass `--listen 0.0.0.0` (by default it listens only on `127.0.0.1`):

```bash
PRONTARO_KEY="$PRONTARO_KEY" prontaro forward 15432 db.example.com:5432 --listen 0.0.0.0 --no-input --json
```

In non-TTY scripts, `forward` prints `<listen_addr>` (for example, `127.0.0.1:15432`) to `stdout` once the local listener is ready.

## How it works

```text
Your app / psql / mongosh
  ──(1. TCP to 127.0.0.1:15432)──▶
prontaro forward (local CLI process)
  ──(2. TLS 1.2+ with HTTP CONNECT on :443)──▶
Prontaro entry node
  ──(3. TCP bound to 203.0.113.10)──▶  db.example.com:5432
```

On first launch, `prontaro` obtains proxy credentials for your IP automatically. Traffic runs through your IP’s HTTPS proxy, and client TLS passes to the remote server without decryption.

## Resilience, credential rotation, and background service

- **Starts without the API:** after the first launch, credentials and IP selection stay cached locally, so `prontaro forward` connects straight to the Prontaro server even if the dashboard or API is temporarily unreachable.
- **Automatic reconnect:** during a server switch or restart, the local port `127.0.0.1:<port>` stays open. Active streams drop, and new local connections wait and connect once the server responds.
- **Credential rotation:** run `prontaro forward <port> <host:port> --new-credentials` to issue fresh credentials (existing From and To access rules are preserved).
- **Background service (Linux and macOS):** `prontaro service install -- forward 15432 db.example.com:5432 --ip 203.0.113.10`. On Windows, run it in a terminal or via Task Scheduler ([Windows setup](https://prontaro.com/docs/cli/windows.md)).

## Limits and notes

- **TCP over IPv4 only.** By default the listener binds to `127.0.0.1` (override with `--listen <addr>`). UDP and direct IPv6 destination addresses are not supported.
- **Not part of `prontaro run`.** `prontaro run` manages inbound tunnels only; start each `forward` process or service individually.
- **Same caps as the HTTP proxy.** Outbound connection caps, monthly traffic, and built-in destination blocks apply identically (see [Usage, limits & quotas](https://prontaro.com/docs/billing/limits.md)).

## FAQ

### Does `prontaro forward` count toward the per-IP proxy credential limit?

Yes. `forward` creates one managed credential set per CLI token and IP — visible in the [dashboard](https://my.prontaro.com/ips) (for usage and To rules). Multiple `forward` commands with the same token and IP reuse it.

### Why does `forward` say “waiting for them to reach the server”?

On first launch (or with `--new-credentials`), new proxy credentials take a few seconds to reach Prontaro’s servers. `prontaro forward` holds incoming local connections for up to 15 seconds while waiting so your client connects as soon as the server accepts them.

### Why do I see `This account has no dedicated IPv4 address`?

`prontaro forward` requires an allocated static IPv4 on Dedicated or Pro. Add an IP under [IP addresses](https://my.prontaro.com/ips) first.

### What to check if `prontaro forward` doesn’t connect?

Make sure the `prontaro forward` process is running. If the connection hangs, check the address, the port, and the firewall. Refusals from the Prontaro server, such as from the To list, show up in [Logs](https://my.prontaro.com/journal).

## Next steps

- [Connect to MongoDB Atlas](https://prontaro.com/docs/integrations/mongodb-atlas.md) — step-by-step cloud database connection from a dedicated IP.
- [Background services (Linux & macOS)](https://prontaro.com/docs/cli/service.md) — run `prontaro forward` as a persistent OS service.
- [SSH, SFTP, and databases behind NAT](https://prontaro.com/docs/tunnels/ssh-and-db.md) — end-to-end outbound and inbound setups for SSH, SFTP, and databases.
- [TCP tunnels](https://prontaro.com/docs/tunnels/tcp.md) — accept inbound TCP connections from the internet onto your local server.
- [HTTP & SOCKS5 proxy](https://prontaro.com/docs/outbound/proxy.md) — connect directly without running a local CLI when your client supports proxies.
