LanguageGB
Databases

Connect your app to PostgreSQL

Put the connection string into your app and confirm it can read and write.

What this covers

Your app connects with a DATABASE_URL, the standard PostgreSQL connection string. Your app reaches the database over the public endpoint on port 5432, where TLS is required — so the database has to be opened to external connections first. That endpoint is per-database and off until you turn it on.

Before you start

Have the database created, and know where your framework reads environment variables from.

How to do it

  1. Open your app's service page and go to the Database tab → Connection.
  2. Check that external access is on. New databases are opened automatically, so it should already be — but if it is off, turn it on: your app connects over the public endpoint, and nothing else will work.
  3. Select Show connection details and copy DATABASE_URL exactly. It already contains the host, port, user, password, database name and sslmode=require.
  4. Add it to your app's environment variables in the portal, then redeploy.
  5. Run your migrations. The Django runtime runs them for you on every deploy; other runtimes need them in your build or start command.
  6. Open the Tables tab in the console to confirm the tables exist and hold rows.

What our team checks

Support can check that the variable is present in the running app and that the database is reachable from your runtime node.

Next step

Set DATABASE_URL in your app's environment, redeploy, and confirm a write from your app shows up in the Tables tab.

Contact Support