Postgres
Create a Postgres database, give it to an app as DATABASE_URL, and look inside it from the
dashboard.
Create a database
Open Databases in the dashboard, choose New database, give it a name and choose Create.
A name is 2 to 32 characters of lowercase letters, digits and underscores, starting with a letter, and is unique within your workspace. The connection string is shown once the database is created, and you can reveal it again from the list at any time.
You can also create one from an app's Settings tab with Create and attach, which does both steps below at once.
Create one with the app
A first deploy through the API can create its database too. Send "with_database": true
with POST /apps or POST /apps/deploy-git, or with_database=true as a form field with
POST /apps/upload. Passive creates a database named after the app, with each - turned
into _ (and a db_ prefix if the name starts with a digit), and the app's first deploy
already has DATABASE_URL. If another database in your workspace has that name, a short
suffix is added. The response carries the database and, for a session or a key with
db:credentials, its connection string.
- If the deploy fails before it is accepted, the database is deleted again and you get the deploy's error.
- Once the deploy is accepted, the database stays attached, even if the build fails later. Fix the build and redeploy; the app keeps the same database.
- A static site is refused, and so is a request whose
envalready setsDATABASE_URL. - An API key needs
db:writeas well asapps:writeto use it.
Attach it to an app
On the app's Settings tab, under Attach a database, choose the database and Attach.
- Passive adds
DATABASE_URLto the app's environment and rebuilds and redeploys the app with it. That can take a few minutes; the button says what it is doing until it is done. - An app has at most one database. To change it, detach the old one first.
- A static site cannot have a database: it has no server to connect from.
Your app reads the connection string from DATABASE_URL, as most frameworks and Postgres
clients expect:
postgresql://<role>:<password>@db.passivedev.com:5432/<database>?sslmode=require
The connection is encrypted, and a connection without TLS is refused. The server's
certificate is self-signed for now, so use sslmode=require as the URL does, not
verify-full. Each database has its own role, limited to 40 connections at once by
default, so one app that opens too many gets the error and the other databases on the
server keep answering. That covers two of a typical framework's default connection pools,
which is what an app holds for a few minutes while a new version takes over from the old
one. An app that needs more can raise its database's limit with
PATCH /databases/{database_id} and {"connection_limit": n}; the change applies to new
connections without recreating the database.
Detach on the same tab removes DATABASE_URL and redeploys the app without it. The
database and its data are kept.
Pull request previews
A preview of an app with a database never receives that app's DATABASE_URL. Instead it
gets a database of its own, named after the app's database with _pr<number> at the end,
and DATABASE_URL points there. Before the preview starts, Passive copies the app's
database structure into it: its tables, columns and indexes, and none of its rows. If the
copy cannot be made, the preview's database starts empty instead, and the preview's
deployment timeline says why. No data from the app's database is ever copied. It appears in your list of databases marked as a preview's, cannot
be attached to another app, and is deleted with its data when the pull request closes. A
preview of an app without a database gets none.
Browse and query
Browse data on the app's Settings tab, or Browse on the Databases list, opens the database. It has three tabs.
- Browser lists the tables and their columns, and shows a table's rows one page at a time. Row counts are Postgres's estimates; a table that has not been analysed yet shows its count as unknown rather than 0.
- SQL is a console that runs what you type, as written.
- History lists the statements run in the console.
The console starts read-only: the next Run cannot change data, and Postgres itself refuses a write. Enable write mode lets the next Run change data; the button then reads Run write. Write mode lasts until you leave the SQL tab.
| Limit | Value |
|---|---|
| Statement time | 5 seconds |
| Rows returned | 500 per query |
| Queries at once | 2 per database; a third waits for you to retry |
| Statements per run in read-only mode | 1 |
| History | the last 100 statements, kept 30 days, shared by your workspace |
A multi-statement script needs write mode, and runs as one transaction: if any statement fails, the whole script is rolled back. When a statement fails, the console shows Postgres's own error, with its code.
The console connects as the database's own role, the same one your app uses, so it can do exactly what your app can and nothing more.
Delete a database
Detach it from its app first. Then Delete on the Databases list, and Confirm. The person who created the database or an owner of the workspace can delete it. Deleting removes the database, its data and its console history.
Where your data lives
Databases run on a dedicated database host that runs no app code. They are never stored on a community device, or on any machine that runs apps.
That is deliberate. Whoever operates a machine can read everything that runs on it, so a database on the same machine as apps would be readable by whoever runs that machine. Your app connects to its database over an encrypted connection instead, and the connection string reaches the app only as an environment variable on its own container.
From the API or an agent
- API. The routes are under
/databasesand/apps/{app}/database, and need thedb:*andapps:writepermissions described in API key scopes. The connection string is returned only to a key withdb:credentials. - Agents. An agent connected through the MCP server can create and attach a database, but never sees the connection string and has no SQL tool.