Guides

Databases

Add a database

In a project, click Add service → Database and pick one:

DatabaseImagePortVariable with the connection string
PostgreSQLpostgres:175432DATABASE_URL
MySQLmysql:83306MYSQL_URL
Redisredis:76379REDIS_URL
MongoDBmongo:727017MONGO_URL

Each one gets a generated password and a volume so data survives restarts and redeploys.

Connect it to your app

On your app's Variables tab, add a variable that points at the database:

bash
DATABASE_URL=${{Postgres.DATABASE_URL}}

The part before the dot is the database service's name, and the part after is the variable on it. When your app deploys, the reference is swapped for the real value. If you rename the database, update the reference.

Connection details

Open the database → Database tab to see the private address, the connection URL (hidden until you click the eye) and the tables or keys inside.

Databases are only reachable from services on the same server. They aren't exposed to the internet.

Backups

Scheduled backups are on the way. Until then, export your data with the database's own tool, for example:

bash
pg_dump "$DATABASE_URL" > backup.sql