Databases

A managed Postgres, MySQL, MariaDB, MongoDB, Redis or ClickHouse on one of your servers.

A managed database on one of your servers: Postgres, MySQL, MariaDB, MongoDB, Redis or ClickHouse. Deplo creates it, gives you a connection string, and handles backups, logs, metrics and a console.

Storage -> Databases: every managed database with its engine and connection string
  • One stack per database, named db-<slug>. The slug comes from the name at creation and never changes, so neither does the host apps connect to.
  • Official images: postgres:<v>-alpine, mysql:<v>, mariadb:<v>, mongo:<v>, redis:<v>-alpine, clickhouse/clickhouse-server:<v>. Any published Docker Hub tag works as the version.
  • Credentials are encrypted and masked. Revealing them needs reveal_secrets.

Create one

Pick the engine

Storage -> Databases -> New Database. Type a Name, then pick the Engine and the Version.

The Create database dialog: engine, version, credentials and environment

Set the password

Credentials are optional: blank fields get generated values. Generate fills a strong password you can see. The username and the database name are set once and never change.

Pick the server and the environment

Server shows up when you have more than one. Environment is where the apps that use it live; leave No environment if your apps are not in a project.

A cluster is listed with the servers, with a Cluster badge. The dialog then says what a failover can lose before you create it.

Optional: host port

Turn on Expose publicly and set a Host port (1024-65535, or Generate) only if something outside the server needs it. This needs the Publish ports permission, and can wait.

Click Create database, then connect it to the app that needs it.

Connect an app to it

Connecting gives the app a variable holding the connection string, rewritten at every deploy, so a password rotation or a new public address needs no edit. Use Connected apps -> Connect app on the database's Overview, or Environment -> Add -> Database on the app. Keep or change the variable name and click Connect. It applies on the next deploy; the confirmation offers Redeploy.

EngineVariable
Postgres, MySQL, MariaDBDATABASE_URL
MongoDBMONGODB_URI
RedisREDIS_URL
ClickHouseCLICKHOUSE_URL
DATABASE_URL = postgres://app:••••••@db-orders:5432/orders

The row in the app's variables shows the engine's logo, which opens the database. Only its name can change. Unlink keeps today's value and stops following the database; Delete removes the variable.

Pasting the string connects it too. A variable whose value is exactly the database's connection string, private or public, connects when you save it and keeps its type. One saved before its database existed connects at the next maintenance pass, at most 12 hours later. Activity says DATABASE_URL now follows orders.

  • Anything more or less stays as written, such as ?sslmode=disable or just db-orders. It shows the logo but does not follow the database.
  • Spell the scheme the way your driver wants, and the app keeps that spelling: postgresql:// for postgres://, mariadb:// for mysql://, or a driver such as postgresql+asyncpg:// or mysql+pymysql://.

A build that reads the database. A build does not run on the app's private network, so a framework that queries the database while building (Next.js generating its pages) cannot reach db-orders. With a Host port, the build gets the public address and the running app keeps the private one. Without one, and always in a Compose app, the build gets the private address.

In a Compose app every service reaches it, except one with internal: true, one using network_mode:, and one named after Deplo's own infrastructure. See Compose apps.

Same environment, same server

By name, an app reaches a database only in the same environment and on the same server. Anywhere else the connection uses the database's public address, so turn on Public first. A database that is neither shows dimmed and cannot be connected. See Network isolation.

  • Connect is production only. A pull request preview does not get the variable. Point a preview at its own database with a preview override.
  • When the app can no longer reach the database (one of them moved, or the public address was turned off), its next deploy stops and names the variable. Both sides show Unreachable.
  • Deleting the database deletes the variables that came from it. The delete dialog names the apps.

The overview

A database's overview: connection, networking, health, data and backups

The Connection card holds the connection string (click to reveal), the two addresses, the engine and version, the username, the database name, the server and the Environment.

AddressWhat it isWho uses it
Internaldb-<slug> on the engine's port: 5432 Postgres, 3306 MySQL and MariaDB, 27017 MongoDB, 6379 Redis, 8123 ClickHouseApps in the same environment, on the same server
Public<server>:<host port>, or Not publishedAnything that can reach the server
  • Wrong environment? Pick another in the card's Environment field, or use Move to environment in the database's menu on the list.
  • The switch on the Public row publishes the database. This needs configure_databases and the Publish ports permission.

A published port is not encrypted

The engine's port is opened directly, with no proxy and no certificate. The password is the only protection.

Below it, Connected apps lists the apps that get the connection string, then three tiles: Health (healthcheck, uptime, restarts), Data (disk and memory use) and Backups (last run and schedule). Data shows - when the server's agent is too old or unreachable.

Actions, and which ones delete data

ActionWhat it doesData
Start / Stop / RestartContainer lifecyclekept
RedeployRecreates the container with the same datakept
RebuildSettings -> Advanced -> Danger Zone. Destroys the container and its data volume, then creates an empty database with the same engine, version and credentialserased
DeleteRemoves the database, its volume and every backup it has storederased

Rebuild is a factory reset

The connection string keeps working, so everything looks fine and the data is gone. Restore a backup afterwards to bring it back.

Delete is refused until the host confirms the container and the volume are gone, and when a backup destination cannot be reached. If the host is gone for good, tick Delete it from Deplo anyway: Deplo keeps retrying the teardown on that host.

Settings

Database settings, where the dashboard label changes without touching the connection string
PageWhat is there
GeneralLogo, Database name (a label only), and the Server card to move it
ConnectionExpose publicly with the Host port, and Rotate password
ResourcesCPU and memory limits. See Resource limits
AdvancedConsole, Cron jobs, Restart loop protection, the image, config files, Danger Zone

Rotate password takes a new password, or generates one when left blank. The database must be running. The new connection string is shown once. For Redis and ClickHouse it recreates the container.

Advanced also holds the image fields. They apply on the next Redeploy:

  • Version: any Docker Hub tag. Going down a major version can leave data the engine cannot read.
  • Custom image: replaces the default, e.g. timescale/timescaledb:2.15-pg16. Version is ignored while it is set.
  • Custom command: replaces the start command. For Redis the default carries --requirepass; a command without it removes authentication, and backups stop authenticating too.

Config files set postgresql.conf, my.cnf, redis.conf or an init script: Add file, give it a File name and a Path in the container, write it, then Save and apply. Saving recreates the container. A path inside the engine's data directory is refused.

Move a database to another server

Settings -> General, then Move on the Server card (shown only with more than one server). Deplo stops the database, copies its data to the new server and starts it there. It is offline during the copy. If the copy fails, the move is rolled back and the database stays where it was.

A cluster is in the same list as a group: Any server lets it pick, or pick one of its servers. See Move to one server of a cluster.

Move a database to another team

Settings -> Advanced -> Danger Zone -> Transfer, or Transfer to another team in the database's menu on the list. It needs move_databases in both teams.

The data, the host db-<slug> and the connection string stay. It lands at the new team's top level and restarts once. Backup schedules and cron jobs are removed, and apps of the old team stop reaching it: the dialog names them. Everything the move costs ->

The other tabs

  • Logs, Monitoring and Backups work like for an app.
  • Console opens the engine's own shell (psql, mysql, redis-cli) after a one-time confirmation. Until then, open it from Settings -> Advanced.
  • Cron jobs runs scheduled commands inside the container. The tab appears once you turn it on in Settings -> Advanced. See Cron jobs.

Good to know

  • Redeploy and Rebuild do not work while the database is provisioning.
  • Capabilities: create_databases to create, control_databases for start, stop, restart and redeploy, configure_databases for settings, delete_databases for Rebuild and Delete, move_databases to hand it to another team, open_database_console for the console. Connecting it to an app needs manage_env and reveal_secrets on that app.
  • Version upgrades are not migrations. A major Postgres upgrade refuses to start on older data. Dump, rebuild, restore.

Troubleshooting

SymptomWhat to check
The app cannot resolve the database nameThey are in different Environments, or on different servers.
Authentication fails after a rotateThe app runs with the old password until it redeploys. A connected variable takes the new one on that deploy; a variable written by hand needs updating first.
A deploy stops with "DATABASE_URL comes from orders, which runs on another server"The app cannot reach the connected database. Move one of them, or turn on the database's public address.
Stuck in provisioningThe agent could not pull the image, or the server is unreachable. Check the server's health.

More in Databases and backups.

Next steps

Did this page help you?

On this page