PostgreSQL Database
Every App Platform plan includes a managed PostgreSQL 16 database.
How your app connects
The database is created automatically with your app. Its connection string is injected as the DATABASE_URL environment variable — you do not configure anything.
postgresql://user:password@host:5432/dbnameNode.js (Prisma):
// prisma/schema.prisma
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}Python (SQLAlchemy):
import os
from sqlalchemy import create_engine
engine = create_engine(os.environ['DATABASE_URL'])Go:
db, err := sql.Open("postgres", os.Getenv("DATABASE_URL"))
DATABASE_URLis a system variable. It cannot be edited or deleted, and it is re-applied on every deploy. To use a database you host elsewhere, add your own variable under a different name instead — see Environment Variables.
Backups
Your database is backed up automatically every night, and you can take a
backup yourself at any time.
To take one now:
- Open your app and go to the Backups tab
- Click Create Backup
To restore:
- Go to the Backups tab
- Choose the backup you want and click Restore
Restoring replaces your current database. You will be asked to confirm.
Take a fresh backup first if the current data still matters.
We keep your 7 most recent backups. Even with nightly backups running, it is
worth taking one yourself immediately before a schema migration, a bulk delete,
or a major release — that way your recovery point is exactly where you want it.
Migrations
Run migrations automatically at deploy time using a release step in your Procfile:
release: npx prisma migrate deploy
web: node server.jsThe release process runs once, before the web process starts.
Limits
- One database per app
- No direct connection from your own machine — your app reaches the database internally
- Database size counts towards your plan's storage allowance
If your app cannot reach its database
Do not change DATABASE_URL — the value we inject is correct. If your app cannot connect, check the Logs tab for the exact error and open a ticket with your app name. A connection failure on a correctly injected DATABASE_URL is something for us to fix, not you.