/app/.vertra/certs/<database_id>/ folder. Postgres and MongoDB carry the certificate paths inside the URL, so most drivers need no extra code. Redis and MySQL need a few lines that read the certificate paths from variables.
This page covers the stack’s own connection. For the connection details of a database you reach from outside (your computer, another service), see How do I connect to each engine? and the connection guide.
Variables the platform injects
Each connection between an app and a database creates managed variables in the app. The default names:- Postgres: the URL already carries
sslmode,sslrootcert,sslcertandsslkey. Always pass the URL to the driver: thePG*variables alone are not enough for some drivers, such as the Node.jspg. - MongoDB: the URI carries
tls=true, the CA file (ca.pem) and the client certificate file (client.pem, certificate and key together). - Redis and MySQL: the URL does not carry files, so the paths come in their own variables. Read them in code.
/app/.vertra/certs/<database_id>/ as ca.pem, client.crt and client.key, plus client.pem (certificate and key in one file, used by MongoDB) and client.p12 (for Prisma 6) when the connection needs them. They are read-only and owned by the platform, and the variables hold absolute paths. Your app process reads them normally. The folder is reserved: your deploys, restores and rollbacks do not delete or bring back old certificates, it stays out of downloads and snapshots, and the platform rewrites the files on each start.
You can edit the variable names before creating a connection.
Managed variables
A variable created by a connection shows managed by the stack in the app and updates by itself when the database changes its password or certificate. Restart the app after such a change; the platform tells you which apps need it. If you edit a managed variable by hand, it stops being managed and becomes an ordinary variable, with a warning. When you reset a database’s certificates, the platform rewrites the files in the connected apps and asks for a restart.More than one database of the same type
A stack can hold several databases of the same engine, for example one Redis for cache and another for a queue. Each is a normal database with its own memory. The first of each engine gets the default name (REDIS_URL); the others take the service name as a prefix (QUEUE_REDIS_URL, ANALYTICS_DATABASE_URL), and you can edit the names before creating. One database can be connected to several apps in the stack (for example an API and a worker on the same Postgres), but a database belongs to one stack only.
Code by language
The names below are the defaults; if you renamed a variable, use your name. The How to connect panel in the dashboard (andget_connection_info with app_id in the MCP server, or the stack connection route) shows the same code with your actual variable names, in the language of the app.
- Node.js
- Python
- Go
Postgres (pg)
MongoDB (mongodb)
Redis (ioredis)
mysql2), read MYSQL_URL and pass ssl: { ca, cert, key } from the MYSQL_SSL_* files; mysql2 does not check that the host name matches the certificate. Prisma 7 uses the pg adapter, so the same DATABASE_URL works. For the other drivers, see How do I connect to each engine?.If the connection fails
- Handshake or authentication failure: the client certificate is missing. Confirm the app passes the URL (Postgres, MongoDB) or reads the certificate variables (Redis, MySQL).
- The variable is empty or old: restart the app after a password or certificate change on the database.
- Certificate files missing from
/app/.vertra/certs/: the platform rewrites them on each start. Restart the app; do not create the folder yourself.
Related
Stacks
Add or remove a database in a stack.
Databases
Engines, certificates, resets and limits.