Guides

Managed databases

Create PostgreSQL, MySQL, MongoDB, Redis or SQLite, connect it to an app with “Use in app”, reach it from your laptop, and back it up.

Engines

  • PostgreSQL (18, 17, 16, 15), MySQL (26, 9, 8), MongoDB (8, 7, 6, 5) and Redis (8, 7, 6) each run as their own server inside your workspace.
  • SQLite is different: it’s a single .db file on a persistent disk mounted into ONE app, not a server. It has no public access, password rotation or backups of its own.

Create a database

  1. 1Open Databases → New database and pick the Engine and Version.
  2. 2Give it a Name and a Short name (used in its hostname), then a Database name, Username and Password — or generate a password.
  3. 3Leave “Allow public internet access” off unless you need to connect from outside (see below).
  4. 4Optionally pick “Make available to” now — the same thing as “Use in app” later — and click Create database.
  • SQLite needs an App instead: the file is created at /data/<short-name>.db inside that app’s container. Redeploy the app after creating it so the disk mounts.

Connect it to an app (“Use in app”)

  1. 1Open the database and click Use in app.
  2. 2Under “Make available to” choose “Whole workspace — all apps” or “A specific app” (then the app).
  3. 3Check the Secret key — the env-var name your app reads — and save. The connection string is stored as an encrypted secret at that scope.
  4. 4Redeploy the app. Secrets are injected when a build runs and when the container starts, so a running app doesn’t see the new value until then.
What gets injected (default key names)
DATABASE_URL=postgresql://<user>:<password>@<db-container>:5432/<db>             # PostgreSQL
DATABASE_URL=mysql://<user>:<password>@<db-container>:3306/<db>                  # MySQL
MONGODB_URI=mongodb://<user>:<password>@<db-container>:27017/<db>?authSource=admin # MongoDB
REDIS_URL=redis://<user>:<password>@<db-container>:6379/0                       # Redis
DATABASE_URL=file:/data/<short-name>.db                                         # SQLite
  • This is the internal address: your app reaches the database over the workspace’s private network by its container name, without TLS. It works for apps on Shipyard only — it isn’t reachable from your laptop.
Don’t force TLS on the internal connection (sslmode=require, ssl: true, a CA bundle). There is no TLS on the private network, so those settings fail with errors like “self-signed certificate” or “server does not support SSL”. If your code reads a different name than DATABASE_URL / MONGODB_URI / REDIS_URL, change the Secret key instead of the code.
  • Rotated the password? Click Use in app again to push the new connection string, then redeploy the apps that use it.

Connect from code

Node — PostgreSQL (pg)
const { Pool } = require('pg');
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
const { rows } = await pool.query('select now()');
Node — MySQL (mysql2)
const mysql = require('mysql2/promise');
const pool = mysql.createPool({ uri: process.env.DATABASE_URL });
const [rows] = await pool.query('select 1');
Node — MongoDB driver
const { MongoClient } = require('mongodb');
const client = new MongoClient(process.env.MONGODB_URI);
await client.connect();
const db = client.db(); // the database named in the URI
Python — psycopg (v3)
import os, psycopg
with psycopg.connect(os.environ["DATABASE_URL"]) as conn:
    print(conn.execute("select now()").fetchone())
Python — SQLAlchemy
import os
from sqlalchemy import create_engine
# SQLAlchemy picks the driver from the scheme: postgresql+psycopg:// for psycopg 3
url = os.environ["DATABASE_URL"].replace("postgresql://", "postgresql+psycopg://", 1)
engine = create_engine(url, pool_pre_ping=True)
Django — settings.py (with dj-database-url)
import dj_database_url
DATABASES = {"default": dj_database_url.config(conn_max_age=600)}  # reads DATABASE_URL
  • Prisma and most ORMs read DATABASE_URL directly. A new database is empty: run your migrations on start (see “Database has no tables” in the troubleshooting reference).

Connect from your laptop

  1. 1Turn on public access: “Allow public internet access” at create time, or Make public on a running database. PostgreSQL and MySQL restart briefly to open their port; the data is kept.
  2. 2In the connection panel click Reveal, then Copy. This is the public connection string, and it uses TLS.
  3. 3Paste it into your client or GUI tool.
psql "postgresql://<user>:<password>@<host>:<port>/<db>?sslmode=require"
mongosh "mongodb://<user>:<password>@<host>:443/<db>?tls=true&authSource=admin"
  • PostgreSQL and MySQL get their own published port; MongoDB and Redis are reached on port 443 by hostname (Redis as rediss://).
A public database is protected only by its password. Use a strong one and click Make private when you’re done — your apps keep working, because they use the internal address.

Backups & restore

  • Back up now (top of the database page) takes an on-demand dump. The database must be running.
  • The Backups list shows each backup’s status and size. Download any successful one, or click Restore → Restore & overwrite to load it back.
Restore replaces ALL current data in the database with the backup’s contents and can’t be undone. Take a fresh backup first if you might need what’s there now.
  • Tick “Back this database up every night” to include it in the workspace’s nightly archive, kept off the server. Each database is chosen separately, and new databases start excluded.
  • SQLite has no separate backups — it’s archived with the app it belongs to.