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

> ## Agent Instructions
> These are the docs for Sevalla, a platform for deploying applications, databases, static sites, object storage and load balancers. The dashboard is at https://app.sevalla.com.
> Bold text in steps is an exact dashboard label.
> To act on a Sevalla account, prefer the Sevalla MCP server (https://mcp.sevalla.com/mcp, see https://docs.sevalla.com/ai-agents/overview.md), then the Sevalla CLI (https://docs.sevalla.com/developer-tools/cli.md), then the REST API (https://api-docs.sevalla.com, OpenAPI spec at https://api.sevalla.com/v3/openapi.json).
> Every page index is at https://docs.sevalla.com/llms.txt.

# Connect to a database

> Connect applications to a database over the private network, turn on the external connection, restrict it by IP address, encrypt connections with TLS, and change the password.

You connect to a database in one of two ways: an **internal connection** from an application in the same location, over Sevalla's private network, or the **external connection** from anywhere on the internet. Both use the same database, user and password; only the hostname and port differ.

## Choose a connection

| | Internal connection | External connection |
| - | - | - |
| Who connects | Sevalla applications in the same location as the database | Any client: your computer, CI, services outside Sevalla, applications in other locations |
| Network | Private network inside the location | Public internet |
| Hostname and port | Internal hostname, the engine's default port | A public hostname and port of its own |
| Default | Off until you connect an application | Off until you enable it |
| Access control | Only connected applications | Database password, plus optional [IP restrictions](#restrict-access-by-ip-address) |
| Encryption | [TLS](#encrypt-connections-with-tls), optional | [TLS](#encrypt-connections-with-tls), optional; required for Redis and Valkey |

Use an internal connection whenever the client is a Sevalla application in the same location: it's faster and never leaves the private network. Use the external connection for everything else.

## Find the connection details

The database's **Overview** tab has a **Connection** card. Switch between **Internal** and **External** to see the **Host**, **Port**, **Database**, **User**, **Password** and **URL** (Redis and Valkey have no database or user). Click the eye icon to reveal a secret and the copy icon to copy a value. Under **Connect from code**, the card shows examples for the **CLI**, **Node.js**, **Python** and **PHP** that read the connection from the environment variables an internal connection adds.

The **Networking** tab shows the same hostnames, ports and URLs under **External connection** and **Internal connection**.

| Engine | Internal hostname | Port | URL format |
| - | - | - | - |
| PostgreSQL | `orders-db-k3j4h-postgresql.orders-db-k3j4h.svc.cluster.local` | `5432` | `postgres://user:password@host:5432/database` |
| MySQL | `orders-db-k3j4h-mysql.orders-db-k3j4h.svc.cluster.local` | `3306` | `mysql://user:password@host:3306/database` |
| MariaDB | `orders-db-k3j4h-mariadb.orders-db-k3j4h.svc.cluster.local` | `3306` | `mysql://user:password@host:3306/database` |
| Redis | `orders-db-k3j4h-redis-master.orders-db-k3j4h.svc.cluster.local` | `6379` | `redis://:password@host:6379/0` |
| Valkey | `orders-db-k3j4h-valkey-master.orders-db-k3j4h.svc.cluster.local` | `6379` | `redis://:password@host:6379/0` |

The internal hostname is built from the database's permanent name (`orders-db-k3j4h` in the table). The URL percent-encodes special characters in the password. Valkey URLs start with `redis://`, like Redis URLs, because the protocol is the same. A variable an internal connection added before Oct 30, 2026 can still start with `valkey://`; for a client that accepts only `redis://` URLs, change the scheme in the variable's value.

## Connect an application

An internal connection opens the private network between an application and the database, and can add the connection details to the application's environment variables. The application must be in the same location as the database. You can also start from the application's **Networking** tab; see [Internal connections](https://docs.sevalla.com/applications/networking.md#internal-connections).

**1. Open the database's networking**

In the sidebar, click **Databases**, then click the database. Click the **Networking** tab.

**2. Add the connection**

Under **Private networking**, in **Connected applications**, click **Add internal connection**.

**3. Pick the application**

Choose the **Application**. Applications that are already connected, suspended or in another location are listed but can't be chosen.

**4. Add the environment variables**

Turn on **Add environment variables to the application**. Keep **Available during runtime** and **Available during buildtime** checked, or clear the one you don't need. Rename a key if your application expects another name, or click **Add another** to add a variable.

**5. Save**

Click **Add internal connection**.

**6. Deploy the application**

Deploy the application so its processes get the new variables. See [Deployments](https://docs.sevalla.com/applications/deployments.md).

The application appears under **Connected applications**. The connection works as soon as it's added; the environment variables reach the application with its next deployment.

![The Add internal connection sheet with an application chosen, Add environment variables to the application turned on, and the DB\_HOST, DB\_PORT, DB\_DATABASE, DB\_USERNAME, DB\_PASSWORD and DB\_URL variables](https://assets.sevalla.com/screenshots/light/database-networking-internal-connection-add.png)

### Environment variables an internal connection adds

| PostgreSQL, MySQL, MariaDB | Redis, Valkey | Value |
| - | - | - |
| `DB_HOST` | `REDIS_HOST` | Internal hostname |
| `DB_PORT` | `REDIS_PORT` | Internal port |
| `DB_DATABASE` | | Database name |
| `DB_USERNAME` | | Database user |
| `DB_PASSWORD` | `REDIS_PASSWORD` | Database password |
| `DB_URL` | `REDIS_URL` | Internal connection URL |

* The variables are off unless you turn on **Add environment variables to the application**.
* For an application deployed from a Docker image, the variables are available at runtime only (images aren't built).
* The form stops you with `This key already exists on the application` if the application already has a variable with that key, `Duplicate key` if two rows share a key, and `Select at least one option` if neither runtime nor buildtime is checked.
* The variables are copies: they don't change when the database changes. After you [change the password](#change-the-database-password), update `DB_PASSWORD` and `DB_URL` (or `REDIS_PASSWORD` and `REDIS_URL`) on each application yourself. See [Environment variables](https://docs.sevalla.com/applications/environment-variables.md).

### Disconnect an application

On the database's **Networking** tab, under **Connected applications**, click the trash icon next to the application, then click **Disconnect**. The application can no longer reach the database over the private network. Its environment variables stay as they are; delete them on the application's **Environment variables** tab if it no longer needs them.

## Enable the external connection

The external connection gives the database a public hostname and port. It's off for a new database.

**1. Open the database's networking**

In the sidebar, click **Databases**, then click the database. Click the **Networking** tab.

**2. Enable it**

Under **Public networking**, in **External connection**, click **Enable**, then click **Enable** in the dialog.

The status changes to **Updating external connection**, then the section shows **Enabled** with the **External hostname**, **External port** and **External connection URL**. The **Overview** tab's **Connection** card shows them under **External**, where **Enable external connection** does the same.

* The external hostname starts with the database's permanent name, for example `orders-db-k3j4h.ext.sevalla.app`, and the port is assigned by Sevalla. Copy both from the dashboard; don't guess them.
* Anyone with the hostname, port, user and password can connect. Limit who can reach it with [IP restrictions](#restrict-access-by-ip-address).
* Turning the external connection off and on again keeps the same hostname and port.
* [Suspending the database](https://docs.sevalla.com/databases/settings.md#suspend-a-database) turns the external connection off. Activating the database doesn't turn it back on: enable it again.

> [!NOTE]
>
> Databases that had their external connection on before the move to the current endpoints also had a legacy hostname of the form `<cluster>.proxy.sevalla.app`, with a port from 30000 to 30999. Those legacy hostnames and ports were disabled on Oct 15, 2026, and connections to them fail. If a client still uses one, switch it to the hostname and port the dashboard shows now. When the **Overview** or **Networking** tab shows **Your external connection details have changed**, **Show legacy details** lists the old ones for reference. See [OCI migration](https://docs.sevalla.com/platform/oci-migration.md#legacy-tcp-proxy-and-external-connection-endpoints).

To turn it off, click **Disable** in the same section, then **Disable** in the dialog. The database is no longer reachable from outside Sevalla; applications on internal connections keep working.

## Restrict access by IP address

IP restrictions allow or block clients of the external connection by IP address or CIDR block. They don't affect internal connections or the database studio.

**1. Open the IP restrictions**

On the database's **Networking** tab, under **IP restrictions**, click **Update IP restrictions**.

**2. Choose the restriction**

Click **IP allowlist** to let only the listed addresses connect, or **IP denylist** to block them. **No IP restrictions** lets every address connect.

**3. Enter the addresses**

Enter an address or CIDR block, for example `203.0.113.10` or `198.51.100.0/24`. Click **Add IP address** for each further entry.

**4. Save**

Click **Update IP restrictions**.

The section shows **IP allowlist active** or **IP denylist active** with the list of addresses.

* Entries are IPv4 addresses in dotted four-part form, IPv6 addresses, or CIDR blocks of either.
* Use public addresses. Private, loopback and link-local addresses (such as `10.0.0.5`, `127.0.0.1` or `169.254.169.254`) are rejected with `Invalid IP address`.
* To reach the database from a Sevalla application in another location, allow that application's egress IP addresses. See [Networking](https://docs.sevalla.com/applications/networking.md).

![The Update IP restrictions sheet with IP allowlist selected and a list of addresses with an Add IP address button](https://assets.sevalla.com/screenshots/light/database-networking-ip-allowlist.png)

## Encrypt connections with TLS

Databases accept TLS connections. A new database has TLS on from the start; a database created before TLS was available gets it when you [enable it](#enable-tls-on-an-older-database). TLS is available, not required: clients without TLS keep working, except on the external connection of Redis and Valkey, which accepts only TLS.

| Engine | Internal connection | External connection |
| - | - | - |
| PostgreSQL | TLS or plain, on port `5432` | TLS or plain, on the external port |
| MySQL, MariaDB | TLS or plain, on port `3306` | TLS or plain, on the external port |
| Redis, Valkey | TLS on port `6380`, plain on port `6379` | TLS only, on the external port |

Each database has a CA certificate of its own, which signs its server certificate. The server certificate names the internal hostnames and the external hostname, so a client can verify both the certificate and the hostname. PostgreSQL, MySQL and MariaDB clients with their default settings already use TLS when the server offers it, but they don't verify the server: for that, give them the CA certificate.

### Find the CA certificate and TLS URLs

On the database's **Networking** tab, under **Encryption**, the **TLS** section shows **Enabled** or **Disabled**. The **Overview** tab's **Encryption** card shows the same status. With TLS on, the **TLS** section has:

* **Download CA certificate**, which saves the CA certificate as `<name>-ca.crt`, where `<name>` is the database's permanent name (for example `orders-db-k3j4h-ca.crt`).
* **Internal TLS connection URL** and, while the external connection is on, **External TLS connection URL**. Both verify the server against the CA certificate.

| Engine | TLS URL format |
| - | - |
| PostgreSQL | `postgres://user:password@host:5432/database?sslmode=verify-full&sslrootcert=orders-db-k3j4h-ca.crt` |
| MySQL, MariaDB | `mysql://user:password@host:3306/database?ssl-mode=VERIFY_IDENTITY&ssl-ca=orders-db-k3j4h-ca.crt` |
| Redis, Valkey | `rediss://:password@host:6380/0` (internal), `rediss://:password@host:<external port>/0` (external) |

The PostgreSQL, MySQL and MariaDB URLs give the CA certificate as a relative path: save `<name>-ca.crt` in your application's working directory. Redis and Valkey clients take the CA certificate as a separate option, for example `redis-cli --cacert orders-db-k3j4h-ca.crt`.

The environment variables an internal connection adds, such as `DB_URL` and `REDIS_URL`, don't use TLS. To use it from an application, set the TLS URL in the variable yourself and add the CA certificate to the application.

If the section says there's no CA certificate to download, TLS on that database was set up with a certificate of its own. Ask [support](https://docs.sevalla.com/support/get-help.md) for it.

![The Encryption group on the Networking tab with TLS enabled, a Download CA certificate button and the internal and external TLS connection URLs](https://assets.sevalla.com/screenshots/light/database-networking-tls.png)

### Enable TLS on an older database

A database created before TLS was available shows TLS as **Disabled** until you enable it.

**1. Open the database's networking**

In the sidebar, click **Databases**, then click the database. Click the **Networking** tab.

**2. Enable TLS**

Under **Encryption**, in **TLS**, click **Enable TLS**, then click **Enable TLS** in the dialog. The **Overview** tab's **Encryption** card has the same button.

The status changes to **Updating** while the database restarts once, which takes up to 3 minutes and closes its live connections. Some PostgreSQL databases turn TLS on without a restart; the dialog says which applies. When the status is **Ready** again, the **TLS** section shows **Enabled** and the CA certificate.

* **Enable TLS** is unavailable while the database is suspended (`Activate the database to enable TLS.`), while its status isn't **Ready** (`TLS can be enabled once the database is ready.`), and for users who can't update the database.
* Connections without TLS keep working, except on the external connection of Redis and Valkey.

> [!WARNING]
>
> You can't turn TLS off again. On Redis and Valkey, the external connection accepts only TLS afterwards: switch external clients to `rediss://` with the CA certificate before you enable it.

![The Enable TLS dialog for a PostgreSQL database, which says TLS turns on without a restart, connections without TLS keep working and this can't be undone](https://assets.sevalla.com/screenshots/light/database-networking-tls-enable.png)

## Connect from the command line

With the external connection on, connect with the engine's own client and the values from the **External** tab. Replace the hostname, port, user, database and CA certificate file in these examples with yours; each client asks for the password. The examples verify the server over TLS with the [CA certificate](#find-the-ca-certificate-and-tls-urls). PostgreSQL, MySQL and MariaDB also accept plain connections, so their TLS options (`sslmode` and `sslrootcert`, `--ssl*`) are optional. A Redis or Valkey database with TLS on accepts only TLS on the external connection: keep `--tls` and `--cacert`, and leave them out only for a database without TLS.

```bash PostgreSQL theme={"theme":{"light":"github-dark-default","dark":"github-dark-default"}}
psql "postgres://orders@orders-db-k3j4h.ext.sevalla.app:20145/orders?sslmode=verify-full&sslrootcert=orders-db-k3j4h-ca.crt"
```

```bash MySQL theme={"theme":{"light":"github-dark-default","dark":"github-dark-default"}}
mysql -h orders-db-k3j4h.ext.sevalla.app -P 20145 -u orders -p --ssl-mode=VERIFY_IDENTITY --ssl-ca=orders-db-k3j4h-ca.crt orders
```

```bash MariaDB theme={"theme":{"light":"github-dark-default","dark":"github-dark-default"}}
mariadb -h orders-db-k3j4h.ext.sevalla.app -P 20145 -u orders -p --ssl --ssl-ca=orders-db-k3j4h-ca.crt --ssl-verify-server-cert orders
```

```bash Redis theme={"theme":{"light":"github-dark-default","dark":"github-dark-default"}}
REDISCLI_AUTH='<password>' redis-cli -h orders-db-k3j4h.ext.sevalla.app -p 20145 --tls --cacert orders-db-k3j4h-ca.crt
```

```bash Valkey theme={"theme":{"light":"github-dark-default","dark":"github-dark-default"}}
REDISCLI_AUTH='<password>' valkey-cli -h orders-db-k3j4h.ext.sevalla.app -p 20145 --tls --cacert orders-db-k3j4h-ca.crt
```

For Redis and Valkey, replace `<password>` with the database password. `REDISCLI_AUTH` keeps it out of the client's arguments (and avoids the warning `-a` prints); `valkey-cli` 7.2 and 8.1 read only this variable, 9.0 also reads `VALKEYCLI_AUTH`.

## Connect with TablePlus

[TablePlus](https://tableplus.com) works with every engine Sevalla offers. Any client for your engine works the same way: give it the external hostname, port, user, password and database.

The fastest way: with the external connection on, click **Open deeplink** on the **Overview** tab's **Connection** card (under **External**) or on the **Networking** tab. It opens the external connection URL in the application registered for it, such as TablePlus.

To add the connection by hand:

**1. Create a connection**

In TablePlus, click **Create a new connection**, choose the engine, then click **Create**. For Valkey, choose **Redis**.

![The TablePlus new connection dialog with a grid of database types and the Create button](https://mintcdn.com/sevalla/a3xHmYExJQcu1_oY/images/tableplus/app-light.png?fit=max\&auto=format\&n=a3xHmYExJQcu1_oY\&q=85\&s=073e290c4981e4df1cd4a651f701a9cf)

**2. Enter the connection details**

Copy the values from the database's **External** connection details into **Host/Socket**, **Port**, **User**, **Password** and **Database**. Redis and Valkey need only the host, port and password.

![The TablePlus PostgreSQL connection form with the Host/Socket, Port, User, Password and Database fields highlighted](https://mintcdn.com/sevalla/a3xHmYExJQcu1_oY/images/tableplus/postgres-connection-light.png?fit=max\&auto=format\&n=a3xHmYExJQcu1_oY\&q=85\&s=ee656bbeff0669617d9e219ace1c8b64)

**3. Connect**

Click **Test** to check the details, then click **Connect**.

## Change the database password

**1. Open the password card**

In the sidebar, click **Databases**, then click the database. On the **Overview** tab, in the **Password** card, click **Change password**.

**2. Enter the new password**

Enter the **New password**: 4 to 100 characters, letters, numbers and `_ ? < > # @ - = +`. It must differ from the current one.

**3. Save**

Click **Change database password**.

The status changes to **Changing password**, and the database is unavailable for a few minutes. When it's **Ready** again, the new password works for internal and external connections and the connection URLs show it. If the status changes to **Password change failed**, the old password still works: try again.

Update the password in every client and application that connects, including the `DB_PASSWORD` and `DB_URL` (or `REDIS_PASSWORD` and `REDIS_URL`) variables of [connected applications](#environment-variables-an-internal-connection-adds), then deploy those applications. You can't change the password while the database is suspended or while another change is running.

![The Change database password sheet with a New password field and the allowed characters](https://assets.sevalla.com/screenshots/light/database-overview-password-change.png)

## API and CLI

| Task | API | CLI |
| - | - | - |
| List internal connections | [List internal connections](https://api-docs.sevalla.com/v3/databases/list-internal-connections) | `sevalla databases connections internal-list --db-id <id>` |
| Connect an application | [Create internal connection](https://api-docs.sevalla.com/v3/databases/create-internal-connection) | `sevalla databases connections internal-create <db-id> --target-id <app-id>` |
| Disconnect an application | [Delete internal connection](https://api-docs.sevalla.com/v3/databases/delete-internal-connection) | `sevalla databases connections internal-delete <db-id> <connection-id> --confirm` |
| Turn the external connection on or off | [Toggle external connection](https://api-docs.sevalla.com/v3/databases/toggle-external-connection) | `sevalla databases connections external-toggle <db-id>` |
| Get IP restrictions | [Get database IP restriction](https://api-docs.sevalla.com/v3/databases/get-database-ip-restriction) | `sevalla databases ip-restriction get <db-id>` |
| Update IP restrictions | [Update database IP restriction](https://api-docs.sevalla.com/v3/databases/update-database-ip-restriction) | `sevalla databases ip-restriction update <db-id> --type allow --ip-list 203.0.113.10,198.51.100.0/24 --enabled true` |
| Check TLS and get the CA certificate | [Get database](https://api-docs.sevalla.com/v3/databases/get-database) (`tls_enabled`, `tls_ca_certificate`) | `sevalla databases get <id> --json` |
| Enable TLS | `POST /v3/databases/{id}/tls/enable` (`enableDatabaseTlsV3`), which returns `202` and restarts the database | Not available |
| Change the password | [Reset database password](https://api-docs.sevalla.com/v3/databases/reset-database-password) | `sevalla databases reset-password <id> --new-password <password>` |

The API's internal connection endpoint doesn't add environment variables; set them with the application's environment variable endpoints.


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