Connect to PostgreSQL

Connect through the transaction or session pooler with TLS, and restrict network access.

Last updated

Get the connection string

Open PostgreSQL › Connect (or the Connect drawer). It shows:

  • the transaction pooler and session pooler strings, and
  • the project connection block (see Connect once).

Both pooler strings sign in as your database's owner role and require TLS:

Terminal
DATABASE_URL="postgresql://<owner role>:$DB_PASSWORD@<pooler host>:<port>/<database>?sslmode=verify-full"

The page shows a hint for when to use the session pooler. The database password is never shown again after it is created or rotated.

PoolerUse it for
Transaction poolerMany short requests, such as serverless or web handlers
Session poolerClients that need a full session; this is what hosted apps get as DATABASE_URL

Only TLS connections with SCRAM-SHA-256 are accepted, and only with your project's own roles.

Note: The poolers accept connections only from apps hosted on DASTER today. psql, pg_dump or an app hosted elsewhere cannot connect yet. Use the SQL Editor, the API or the data API instead.

SSL certificate

On Settings, SSL › Download certificate saves DASTER's CA as daster-ca.pem. Point your client at it to use sslmode=verify-full.

Pool settings

Settings › Edit pool settings changes the pool size and the client limit:

  • Pool size: from 1 to the size's connection limit minus 3 (7 on Free and Nano).
  • Client limit: 1 to 200, and never smaller than the pool.

Connections now shows database connections against your size's limit, pooler clients, and pooler-to-database connections.

Network restrictions

  1. On Settings › Network restrictions, choose Add restriction.
  2. Enter an IPv4 or IPv6 range and an optional note. Up to 20 ranges.
  3. Save. A sign-in within the last 10 minutes is needed.

An empty list allows every address. Once a range exists, every other address is refused, and connected clients outside the list are disconnected.

Rotate the password

Settings › Rotate creates a new password and connection string, shows them once and revokes the old access.

With the API

  • GET /v1/projects/{projectId}/backend/pooler?organizationId=…: hosts, ports, CA certificate, settings, limits and current use. Never a password.
  • PATCH …/backend/pooler with { "poolSize": 5, "maxClients": 50 }.
  • PUT …/backend/network-rules with { "rules": [{ "cidr": "203.0.113.0/24", "note": "office" }], "confirmed": true }.
  • POST …/backend/credentials with { "confirmed": true } rotates the password.

Note: Not available yet: a dedicated pooler, an IPv4 add-on, network bans and connection logging.