> ## 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.

# Databases - Networking

> Connect to your databases using various clients and tools.

Networking allows you to communicate with your database using one of the following methods:

* An **external connection** involves an internet round-trip, making it significantly slower than internal communication. External connections are turned off by default. We recommend external connections if you are hosting only your database with us, but not your front end. To connect to the database using an external connection, you must [enable public access](/databases/connections#external-connections).
* An **internal connection** stays within our network and is thus much faster and more secure. We recommend this method if you host both your front-end and database with Application Hosting and Database Hosting services.

<Info>
  Internal connections are only available between applications and databases hosted with Application Hosting and Database Hosting services.
</Info>

## Public networking

<Frame caption="Public networking settings for your database.">
  <img className="block dark:hidden" src="https://mintcdn.com/sevalla/8P_1qGnIpPJt22Cp/images/database-public-networking-light.png?fit=max&auto=format&n=8P_1qGnIpPJt22Cp&q=85&s=6328577ce2ba70b261316f3f2b02e4dc" alt="Public networking settings for your database" width="2560" height="908" data-path="images/database-public-networking-light.png" />

  <img className="hidden dark:block" src="https://mintcdn.com/sevalla/8P_1qGnIpPJt22Cp/images/database-public-networking-dark.png?fit=max&auto=format&n=8P_1qGnIpPJt22Cp&q=85&s=6940704edcd3542f2fb2571d0e5e945a" alt="Public networking settings for your database" width="2564" height="916" data-path="images/database-public-networking-dark.png" />
</Frame>

### External connection

To enable or disable external access to your database, select either **Enable** or **Disable**. If public access is enabled, you can use the connection details to [connect to your database](/databases/manage-data/tableplus) via the command line (CLI) or with a database tool.

Click **Open deeplink** to open your database within [TablePlus](https://docs.sevalla.com/databases/manage-data/tableplus).

### IP restrictions

IP restrictions allow you to restrict or block access to specific IP addresses or CIDR blocks. If an unauthorized user (IP address) attempts to access the database, they will receive a **403 – Forbidden error**.

To change your IP restriction settings, click **Update IP Restrictions** and choose from the following:

* **No IP restrictions:** Allows all connections to your database.
* **IP allowlist:** Allows connections only from the specified IP addresses. When you select this option, enter the IP addresses or CIDR notations that should have access to your database. To add multiple entries, click the plus icon after each one. There is no limit to the number of entries.
* **IP denylist:** Blocks connections from specified IP addresses. When you select this option, enter the IP addresses or CIDR notations you want to block from accessing your database. To add multiple entries, click the plus icon after each one. There is no limit to the number of entries.

To save the changes, click **Update IP restrictions**.

<Frame caption="Update the IP restriction settings for your database.">
  <img className="block dark:hidden" src="https://mintcdn.com/sevalla/8P_1qGnIpPJt22Cp/images/database-ip-allowlist-light.png?fit=max&auto=format&n=8P_1qGnIpPJt22Cp&q=85&s=fc9db7a71b5cc858cc502087739e4b86" alt="Update the IP restriction settings for your database" width="1580" height="986" data-path="images/database-ip-allowlist-light.png" />

  <img className="hidden dark:block" src="https://mintcdn.com/sevalla/8P_1qGnIpPJt22Cp/images/database-ip-allowlist-dark.png?fit=max&auto=format&n=8P_1qGnIpPJt22Cp&q=85&s=0712fad5774d140a2cb90b0c126dc864" alt="Update the IP restriction settings for your database" width="1592" height="1004" data-path="images/database-ip-allowlist-dark.png" />
</Frame>

## Private networking

<Frame caption="Private networking settings for your database.">
  <img className="block dark:hidden" src="https://mintcdn.com/sevalla/8P_1qGnIpPJt22Cp/images/database-private-networking-light.png?fit=max&auto=format&n=8P_1qGnIpPJt22Cp&q=85&s=21181f3135af59ce4f4e8b67ea4af5d6" alt="Private networking settings for your database" width="2560" height="1046" data-path="images/database-private-networking-light.png" />

  <img className="hidden dark:block" src="https://mintcdn.com/sevalla/8P_1qGnIpPJt22Cp/images/database-private-networking-dark.png?fit=max&auto=format&n=8P_1qGnIpPJt22Cp&q=85&s=4b97b4b04644462e69c75a55153c5112" alt="Private networking settings for your database" width="2564" height="1054" data-path="images/database-private-networking-dark.png" />
</Frame>

## Add internal connection

<Warning>
  For the time being, internal connections are only supported between applications in the same region. If you're deploying an application and a database, you must choose the same region for both.
</Warning>

You can add internal connections from an application's **Networking** page or a database's **Networking** page. It doesn't matter where you start the process; the result will be the same.

To add a connection from a database to an application, click **Add internal connection**, and select the application you want to connect to.

To automatically populate an application's [environment variables](/applications/environment-variables) from the database connection details, select **Add environment variables to the application**. This automatically populates the environment variables from the database you're connecting to.

Select whether the variables will be available during runtime and/or the build process, and click **Add internal connection**.

Some applications may expect environment variables (keys) with different names. You can edit the names in the list before adding the connection or [**edit them later on the application's Settings page**](/applications/environment-variables).

<Frame caption="Add an internal connection from a database to an application in Sevalla.">
  <img className="block dark:hidden" src="https://mintcdn.com/sevalla/SmxtuQa39gZkt5q5/images/database-add-internal-connection-light.png?fit=max&auto=format&n=SmxtuQa39gZkt5q5&q=85&s=57bf10ab655d9030b4fab8e89639e488" alt="Add an internal connection from a database to an application" width="1176" height="1940" data-path="images/database-add-internal-connection-light.png" />

  <img className="hidden dark:block" src="https://mintcdn.com/sevalla/SmxtuQa39gZkt5q5/images/database-add-internal-connection-dark.png?fit=max&auto=format&n=SmxtuQa39gZkt5q5&q=85&s=925bcb85518cbb2b5058efaf700db073" alt="Add an internal connection from a database to an application" width="1194" height="1928" data-path="images/database-add-internal-connection-dark.png" />
</Frame>

### Ports

[The port](/applications/settings) for internal connections to an application can be defined when you add your application or within your application's **Networking** > **Update port**. The port for internal connections to a database is 3306 and cannot be changed.

For applications, Sevalla automatically sets the `PORT` environment variable. You do not need to define it yourself or hard-code it into the application. When an application is deployed, it is reachable on the internet on ports 80 and 443, and we route those ports to the container on the port defined by your application.

### Remove an internal connection

If you need to remove a connection, go to the Database's **Networking** page, and under **Connected applications**, click the delete (trash can) icon.

<Frame caption="Internal connections between databases and applications.">
  <img className="block dark:hidden" src="https://mintcdn.com/sevalla/SmxtuQa39gZkt5q5/images/connected-applications-light.png?fit=max&auto=format&n=SmxtuQa39gZkt5q5&q=85&s=aeaaf447ded2d294a3da44d73d3bc321" alt="Internal connections between databases and applications" width="2552" height="470" data-path="images/connected-applications-light.png" />

  <img className="hidden dark:block" src="https://mintcdn.com/sevalla/SmxtuQa39gZkt5q5/images/connected-applications-dark.png?fit=max&auto=format&n=SmxtuQa39gZkt5q5&q=85&s=ac7abfbba1ee4fa34d2052eeda43b3f9" alt="Internal connections between databases and applications" width="2562" height="484" data-path="images/connected-applications-dark.png" />
</Frame>

Click **Continue** to confirm and remove the connection between the application and the database.

## Change database password

You can change the database password for your internal and external connections. On the database **Overview** page, within **Manage password**, click **Change password** and enter a new password.

<Frame caption="Change the database password for internal and external connections.">
  <img className="block dark:hidden" src="https://mintcdn.com/sevalla/40BMwYMBrkEyfQ_W/images/change-database-password-light.png?fit=max&auto=format&n=40BMwYMBrkEyfQ_W&q=85&s=c7342ea2431db32f795543c787982ef8" alt="Change the database password" width="1182" height="568" data-path="images/change-database-password-light.png" />

  <img className="hidden dark:block" src="https://mintcdn.com/sevalla/40BMwYMBrkEyfQ_W/images/change-database-password-dark.png?fit=max&auto=format&n=40BMwYMBrkEyfQ_W&q=85&s=92730933da851ac2a330d92c13bdd85a" alt="Change the database password" width="1188" height="548" data-path="images/change-database-password-dark.png" />
</Frame>

When you change the password, you must manually change the password in every client you use to connect to the database and update any other relevant [environment variables](/applications/environment-variables).

Passwords must be at least 8 characters and include at least one lowercase letter, one uppercase letter, a number, and one of the following special characters: ``, & * [ ] : ' $ ` "``
