# SSH tunnel

> Reach a database closed to the internet through your SSH server. The tunnel starts on your device, encrypts all the traffic, and doesn’t go through Pulse.

- Section: Pro tools
- Availability: From the Free plan with your first SSH server and first PostgreSQL database, no limit with Pro and Team. On iPhone, iPad, Mac and Android.
- URL: https://pulse-app.si/en/docs/pro/tunnel

## Why use a tunnel

Use a tunnel for a database that’s closed to the internet and listens only on its own server. You don’t open any database port, and all the traffic is encrypted by SSH.

It’s also a sure way to encrypt the connection to a database, even if the server has no TLS. See [Encryption on the network](https://pulse-app.si/en/docs/pro/connections#network-encryption).

## What happens

1. Pulse first connects to the server over SSH, from the device.
2. It opens a local relay on the device, on `127.0.0.1` and a free port.
3. The database client talks to that relay. SSH carries the traffic to the server, which reaches the database.

So the database’s **Host** field reads from the server’s point of view, not the device’s. Left empty or set to `localhost`, it becomes `127.0.0.1`, over IPv4. For a database in Docker, publish its port on the server, for example `127.0.0.1:5432:5432`.

## Set up a tunnel

### iPhone and iPad

1. First add the [SSH server](https://pulse-app.si/en/docs/pro/connections), with its [key](https://pulse-app.si/en/docs/pro/ssh-keys).
2. In the database form, pick that server under **SSH Tunnel**.
3. In **Host**, enter the database’s address as seen from the server, often `localhost`.
4. Tap **Save**.

### Mac

1. First add the [SSH server](https://pulse-app.si/en/docs/pro/connections), with its [key](https://pulse-app.si/en/docs/pro/ssh-keys).
2. In the database form, turn on **Use an SSH Tunnel**, then pick the **Tunnel Server**.
3. In **Host**, enter the database’s address as seen from the server, often `localhost`.
4. Click **Test**, then confirm.

### Android

1. First add the [SSH server](https://pulse-app.si/en/docs/pro/connections), with its [key](https://pulse-app.si/en/docs/pro/ssh-keys).
2. In the database form, pick that server under **SSH Tunnel**.
3. In **Host**, enter the database’s address as seen from the server, often `localhost`.
4. Tap **Save**.

## From a server’s page

For a server Pulse already monitors, there are fewer steps. In its settings, **Add a Database** asks **Which Database?**, then goes through that server’s tunnel: **On vps-paris-01, via SSH tunnel**. **Test Connection** checks access and **Add and Open** saves it.

If the device doesn’t have a key for that server yet, the app says so and offers **Set Up SSH Key**. The new database then shows on the server’s page, under **Databases and Terminal**.

## If the tunnel fails

| Message | What to do |
| --- | --- |
| **Unreachable: tunnel server not found** | The chosen SSH server is no longer on this device. Add it again or pick another one. |
| **Unreachable: SSH channel refused** | The server refuses forwarding (`AllowTcpForwarding no`), or the database isn’t listening at that address. |
| **No SSH access to vps-paris-01 on this device.** | Install a key on that server from this device. |
| **Add an SSH server first to go through a tunnel.** | There’s no SSH server on this device yet. |

- [SSH keys](https://pulse-app.si/en/docs/pro/ssh-keys)
- [Direct connections](https://pulse-app.si/en/docs/pro/connections)
- [Database client](https://pulse-app.si/en/docs/pro/database)
