Connections are how applications and databases can communicate. There are two main ways this can be achieved:

  • An external connection makes an internet round-trip, so it is much slower than internal communication. We recommend external connections if you are hosting only your database with us but not your front end.
  • 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 your database with Application Hosting and Database Hosting.

External Connections

Note: In the future, external connections will be switched off by default for databases, and we will recommend keeping them off when not in use for security reasons.

Internal Connections

Internal connections use our internal infrastructure for communication and are thus much faster. We recommend using them whenever possible. For more details, see our guide on Adding Internal Connections.

Internal Connections and the Build Process

Internal connections are only available during runtime; they are not available during the build process.

If your application tries to connect to a database using an internal connection during the build process, this causes an error that says the database is not running, which makes the build fail. This is expected because the internal connection is not live during the build; it can only be used during runtime.

There are a couple of ways to work around this.

Option 1: Move the logic that connects to the database from the application’s build command to the start command. For example: if you have a command like prisma migrate in the build process and move that command to the start command, your application will only access the database during runtime, and the build will be successful.

Option 2: Add separate environment variables as needed for the database connection, one available for the build process, and the other only for runtime. The keys can be the same (e.g. DB_CONNECTION_URL) as long as one is only available during the build process and the other is only available during runtime. Use the database’s External connection details (Applications > dbname > Info > External connections) for the values of any variables to be used in the build process.

Remove an Internal Connection

If you need to remove a connection, go to either the Application’s Settings page or the Database’s Info page. Under Internal connections, click the delete (trash can) icon.

Internal connections between databases and applications.
Internal connections between databases and applications.

In the Remove connection modal/pop-up, click Remove connection to confirm and remove the connection between the application and database.

Removing an internal connection between an application and a database.
Removing an internal connection between an application and a database.