Connect to a database

Connect over TLS with the connection strings on the Connection tab, and verify the server with the platform's CA bundle.

Last updated 19 November 2026View as Markdown

Replace orders_admin and orders with your master user and database, and ewdb-0123456789ab with your database's id.

Prerequisites

Get the connection strings

  1. Open the database, then choose Connection.
  2. Copy Application (pooled, port 6432), Direct (port 5432), or, on a cluster, Read replicas (pooled).

Substitute the password:

postgresql://orders_admin:<password>@192.0.2.7:6432/orders?sslmode=require   # applications
postgresql://orders_admin:<password>@192.0.2.7:5432/orders?sslmode=require   # direct
postgresql://orders_admin:<password>@192.0.2.7:6433/orders?sslmode=require   # read replicas, cluster only

The console's strings use the host to connect to: the endpoint's DNS name once the database's certificate carries it, otherwise its address; for a private database, its address or name inside the network.

sslmode=require encrypts the connection. To also verify that you are talking to your database, use verify-full. Node.js is different: node-postgres treats require as verify-full, so a Node app needs the CA bundle even with require; see From Node.js.

Choose the port

The pooler on 6432 runs PgBouncer in transaction mode: a server connection belongs to a client only for one transaction, then serves another client. Anything that lives longer than a transaction does not survive there.

What connects Port
Request handling in a web app or API 6432 (pooled)
Job queues that lock rows or jobs (pg-boss, Graphile Worker, Oban) 5432 (direct)
Migrations, pg_dump, pg_restore, psql sessions 5432 (direct)
Advisory locks, LISTEN/NOTIFY, SET outside a transaction, temporary tables 5432 (direct)
Reads that may lag the primary, on a cluster 6433 (replicas, pooled)

An app with both kinds of code uses two strings, for example DATABASE_URL on 5432 for its worker and migrations, and DATABASE_URL_POOLED on 6432 for its web process.

Timeouts on the pooled port. A client may send statement_timeout, lock_timeout or idle_in_transaction_session_timeout when it connects (node-postgres does when you set those options). On 6432 the pooler accepts the connection but does not apply these values: the role's or the database's own setting applies. Set the timeout there, once:

ALTER ROLE orders_app SET statement_timeout = '30s';

It applies to every new server connection of that role, pooled or direct. For the whole database or every role, use Tune parameters. On 5432 the client's own values apply as usual. Any other unknown startup parameter, search_path included, is refused with unsupported startup parameter; set it with ALTER ROLE … SET too.

Connect with verify-full

  1. On the database's Connection tab, choose Download CA bundle.
  2. Copy Application with certificate check (port 6432) and replace <path-to-…> with where you saved the bundle.

The CA bundle is the same file for every database in the installation. The certificate names the endpoint address and the endpoint's DNS names (<id>.db.apps.<root-domain> for the public endpoint, <id>.private.db.apps.<root-domain> for the private one); verify-full succeeds against any of them. Without sslrootcert, verify-full and verify-ca fail.

From an app deployed on Deutsche Cloud, no download is needed: every container has the CA at /etc/ews/ca/platform-ca.pem, and Node trusts it already (see Bind a managed database in the Apps User Guide). Use that path as sslrootcert.

From Node.js

node-postgres treats sslmode=require as verify-full. Until it trusts the platform's CA, every query fails with self-signed certificate in certificate chain (SELF_SIGNED_CERT_IN_CHAIN).

  1. Download the CA bundle: Download CA bundle on the Connection tab, or dcloud rds ca-bundle download > dcloud-rds-ca.crt. It is a public certificate, safe to commit.

  2. Point NODE_EXTRA_CA_CERTS at it in every process that connects: the web process, the worker, migrations and one-off scripts. In a container image:

    COPY dcloud-rds-ca.crt /etc/ssl/certs/dcloud-rds-ca.crt
    ENV NODE_EXTRA_CA_CERTS=/etc/ssl/certs/dcloud-rds-ca.crt

    On your computer, dcloud rds exec -- <command> does this for one command.

  3. Connect by name (<id>.db.apps.<root-domain>, as the console shows), not by address: node-postgres cannot verify a certificate for an IP host. A database created before the names existed is shown with its address until its certificate is next renewed.

Keep sslmode=require in the string; node-postgres then verifies the server against the bundle. Do not use rejectUnauthorized: false: it turns verification off for the connection.

TLS reference

Where TLS is served every port, direct and pooled
Certificate subject the database id
Certificate names the endpoint address, as an IP, and the endpoint DNS names
Issuer Deutsche Cloud Managed Databases CA (an older installation's CA keeps the name it was made with), one per installation, valid ten years
Certificate validity two years from creation
Renewal automatic, from the machine, once the certificate is inside its last 30 days; connections are not interrupted
Expiry warning written to Activity from 30 days out, once a day; as an error inside 7 days
CA bundle GET /rds/api/ca-bundle → dcloud-rds-ca-bundle.pem
Shown on the database page the certificate's expiry and serial

sslmode values, as libpq treats them against this database:

sslmode Encrypted Verifies the server Needs sslrootcert
disable no no no
allow, prefer yes no no
require yes no no
verify-ca yes issuer only yes
verify-full yes issuer and address yes

With Require TLS on (the default for new databases), a client that does not ask for TLS is refused: no pg_hba.conf entry … no encryption on 5432, SSL required on 6432. With it off, it gets a plaintext connection. See Require TLS.

Result

SELECT version(); answers. With verify-full, the client has checked that the certificate was issued by the platform's CA for the address or name you connected to.

Did this page help you?