Attach a database to an app
Goal: Make a managed Postgres database available to an app as the DATABASE_URL environment variable.
Prerequisites:
- A project with at least one managed Postgres database (created on the Project page).
- An app in the same project.
- Open the app detail page.
- Scroll to the Database card.
- Pick the database from the Attach database… dropdown.
- Click Attach.
- The app pod restarts;
DATABASE_URLis injected as an environment variable.
Detach
Section titled “Detach”Click Detach on the Database card. The pod restarts without the env var.
Change database
Section titled “Change database”Use the Change to… dropdown to swap to a different database in the project. The new DSN replaces the old one on the next restart.
Limits
Section titled “Limits”- One database per app (multiple-DB support is planned).
- Same-project only — the database and app must live in the same project.
- Up to
tier.MaxDatabases()databases per user (Hobby 1 / Dev 1 / Pro 3 / Business 5).