Databases
Ployz adds PostgreSQL, MySQL, Redis or MongoDB to your environment in one step, with a volume for its data, a generated password and the variables your app needs to connect. After that, it's an ordinary service you can change like any other.
Add a database
Section titled “Add a database”- On your project's canvas, click Create.
- Choose Database, then PostgreSQL, MySQL, Redis or MongoDB.
- Its data goes on a 5 GB volume. For more room, click the volume, open its
Settings, type a new Storage limit and press Enter. After you deploy it, grow it on
Ployz Cloud from the volume's panel, or change it with
ployz volume set NAME --size N. - Click Deploy.

You get a service named after the database. Its connection variables are exported for your
other services to reference. They use Railway's names, like PGHOST and PGPASSWORD, so an
app moving from Railway can keep reading them.
The password is a generated value, ${{ secret(32, "a-zA-Z") }}:
32 random letters, plain, not sealed, so anyone who can see the service's variables, its
environment's History or a sync's changes can read it. Each environment makes its own. A
branch or a
pull request's preview that copies the database gets a
new password, which its new, empty volume sets up with, and its connection variables reference it.
A branch that shares production's database reads production's password. To keep a database's
password sealed, seal it from its menu in Variables, and set it in each new branch yourself.
The seal also follows into branches that copied the database before it: unless a branch changed
the password itself, its copy's password turns Not set once you deploy the seal. Set it in
the branch's Variables before the branch deploys. A PostgreSQL or MySQL copy that hasn't set
up its volume yet can't start without it.
| Version | Service | URL variable | Port | User | |
|---|---|---|---|---|---|
| PostgreSQL | 18 | postgres | DATABASE_URL | 5432 | postgres |
| MySQL | 9.4 | mysql | MYSQL_URL | 3306 | root |
| Redis | 8.2 | redis | REDIS_URL | 6379 | default |
| MongoDB | 8.0 | mongodb | MONGO_URL | 27017 | mongo |
PostgreSQL and MySQL start with a database named ployz.
Connect your app
Section titled “Connect your app”- Open your app's service, go to Variables and click New Variable.
- Enter
DATABASE_URLas the Key, and leave Sealed unticked: a sealed value can't hold a reference. - Enter
${{ postgres.DATABASE_URL }}as the Value and click Add. - Click Deploy.

The URL points at the database's private address, like
postgres.internal, so the connection stays on your servers' private network. Ployz starts
the database before your app on every deploy. See Variables for more on
references.
Connect from your laptop
Section titled “Connect from your laptop”Databases have no public address. To reach one from your computer, forward a port to it. This is CLI-only for now (install the CLI first):
# Forward 127.0.0.1:5432 to the database, until you press Ctrl-C
ployz service port-forward postgres 5432:5432
# In another terminal: read the password, then connect
ployz exec postgres -- printenv POSTGRES_PASSWORD
psql -h 127.0.0.1 -U postgres ployz
If 5432 is taken on your laptop, pick another local port, like 15432:5432.
Back up a database
Section titled “Back up a database”A mirror keeps a backup of the database's volume on another of
your servers. For an offsite backup, dump each database on a schedule, from a computer you trust
or a CI job, and store the dumps
away from your servers, such as in object storage. A dump kept on the same server is lost with
it. Dumps are CLI-only for now. Keep -T: it sends the dump to the file unchanged.
# PostgreSQL
ployz exec -T postgres -- pg_dump --format=custom > postgres.dump
# MySQL
ployz exec -T mysql -- sh -c 'mysqldump -u root -p"$MYSQL_ROOT_PASSWORD" --single-transaction "$MYSQL_DATABASE"' > mysql.sql
# Redis
ployz exec -T redis -- sh -c 'redis-cli -a "$REDIS_PASSWORD" --no-auth-warning --rdb -' > redis.rdb
# MongoDB
ployz exec -T mongodb -- sh -c 'mongodump --archive -u "$MONGO_INITDB_ROOT_USERNAME" -p "$MONGO_INITDB_ROOT_PASSWORD" --authenticationDatabase admin' > mongo.archive
Restore a PostgreSQL dump the same way, and try it before you need it:
ployz exec -T postgres -- pg_restore --clean --if-exists -d ployz < postgres.dump
Use a managed database instead
Section titled “Use a managed database instead”To keep your database at a provider such as Amazon RDS, Neon or PlanetScale, skip the preset.
Add the provider's connection URL to your app as a sealed variable named DATABASE_URL, then
click Deploy. If the provider only accepts known IP addresses, allow your servers' public
IPs.
Good to know
Section titled “Good to know”- The password is set once. PostgreSQL, MySQL and MongoDB read their password only when
they first set up their volume. If you change the password variable later, change it in the
database too, or your app can't connect. Redis reads
REDIS_PASSWORDeach time it starts. - A database added before Ployz 0.3.6 keeps its password as it is. Its branches and previews
copy a plain password rather than making a new one. To give each branch its own, set the
password to
${{ secret(32, "a-zA-Z") }}in the branch before its copy first deploys. - A database added while Ployz sealed its password keeps it sealed. Ployz can't read a sealed value, so it never unseals one. Its branches and previews show the password Not set, and their copy of the database can't start until you set it in the branch's Variables.
- Redis can lose its last minute of writes if it crashes.
- Deleting a database deletes its data. Deleting its service in the dashboard also deletes its volume, unless another service mounts it. The deploy asks you to confirm first.