Database environment variables #
Read these variables from process.env on a deployed server. The table shows when Turn Zero Cloud supplies each setting.
The shared pooler sits in front of PostgreSQL and assigns a server connection for each transaction. Your app’s client pool limits how many connections each app process opens. The database role’s limit counts server connections from the shared pooler and direct connections.
| Variable | What it contains | When to use it | When it is present |
|---|---|---|---|
APP_DATABASE_URL |
A secret PostgreSQL connection URL for the environment. Servers on the Unlimited plan and servers with a dedicated database use direct port 5432 at each deploy, promote, rollback, restart or platform redeploy. A new deploy of another server uses the shared pooler on port 6432. | Use this for ordinary queries and transactions. | Where the environment has a database. |
APP_DATABASE_DIRECT_URL |
A secret PostgreSQL connection URL for the same database on direct port 5432. | Use this for work that needs one database session across transactions, such as LISTEN or a session advisory lock. |
On a server environment with a database. |
APP_DATABASE_CONNECTION_LIMIT |
The maximum each process should set for its client pool, from its plan or size on a shared server or its dedicated database size. | Set your client pool's maximum from this value. The PostgreSQL role allows twice this number of server connections in total. | On a server environment with a database and a configured connection limit. |
On a server with a shared database outside the Unlimited plan, promotion, rollback, restart, and platform redeploy keep the APP_DATABASE_URL port recorded with the version. Older versions with no recorded port use 5432.
The usual limit for a shared database is 10 connections per process. Ask your AI tool to read the current database-connection-limit for the size with read_plan_quotas.
After platform staff change the size's connection-limit value, each environment receives the new APP_DATABASE_CONNECTION_LIMIT on its next deploy, promote or restart_application. A running copy keeps the value it started with.
If an environment has a database and its size's connection limit is unset, the platform refuses restart_application with plan_quantity_unset. It also refuses restarts caused by a rename or a change of domain, credential or size. A platform maintenance redeploy still runs. It leaves out the connection-limit setting and writes a warning to the log. The Database package then uses a pool of one connection (The connection limit).
A function with a database receives only APP_DATABASE_URL. It uses port 6432 on a shared database and port 5432 on a dedicated database. Keep the function's own pool to one connection per worker (Add a database).