> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bqto.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Any private IP

> Forward a local port to a private IP and port that you give with --endpoint in bqto Pro, without a lookup, and keep TLS hostname checks working.

> [!NOTE]
>
> This needs bqto Pro.

```sh theme={null}
bqto connect --service cloudsql --project my-project --endpoint 10.0.0.5:5432 \
  --region europe-west1 --network my-vpc
```

`--endpoint IP:PORT` skips the lookup and forwards to that address. Use it for an instance whose
private address bqto cannot find, such as one behind a Private Service Connect endpoint that you
made yourself.

## Rules

* `--endpoint` needs an IPv4 address, `--region` (for the bastion), and `--network`.
* On a terminal, it also needs `--project`. With `--no-input`, the project falls back to the
  default project of gcloud.
* The local port is the remote port plus 10000. Above port 55535, give a local port with `-p`.
* The flag gives a plain TCP forward for any `--service`. The service only names the session.
  If you leave out `--service`, it is `cloudsql`. You get no Kafka proxy and no Cloud Run token.
* With `cloudsql` or `alloydb`, `-- CMD` gets `PGHOST` and `PGPORT`.
* A profile cannot hold `--endpoint`. So `--save` and `bqto profile create` refuse it. `--web`
  refuses it too, because `--web` needs the Cloud Run service that bqto looks up.

## TLS and the hostname

A client that checks the TLS hostname fails on `127.0.0.1`, because the certificate names the
service, such as `api.internal.example.com` on an internal load balancer. After the ready line,
bqto prints one of these lines. Replace `HOST` with the name in the certificate.

| Service and remote port | Line |
| - | - |
| `cloudsql`, `alloydb`, or no `--service` | `try: psql "host=127.0.0.1 port=15432 user=postgres sslmode=require"` |
| Any other, on port 443 | `if TLS checks the hostname, set HOST: curl --connect-to HOST:443:127.0.0.1:10443 https://HOST/` |

Any other service and port gets no line. For Memorystore with TLS, `redis-cli` needs
`--tls --cacert server-ca.pem`. It does not check the hostname.

Other clients need the same two things:

* The real name, for the certificate and SNI.
* `127.0.0.1` with the local port, for the connection.

If a client has no such option, add the line `127.0.0.1 HOST` to `/etc/hosts` and connect to
`HOST:LOCAL_PORT`. If you set `-p` to the remote port, the address of the client stays the same.
On Linux, ports below 1024 need root.

## Check the server certificate

`sslmode=require` encrypts the connection, but it does not check a certificate.
[Cloud SQL](https://docs.bqto.dev/services/cloud-sql.md#check-the-server-certificate) shows how to check the server
certificate through the tunnel.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.