Connect
Pick the pooled or the direct endpoint, take your credentials from the Connect tab, and connect on port 5432, encrypted. Verifying the certificate as well is one switch.
Connecting to a Balta service takes two things: an endpoint, and a role and password. Both are on the service's Connect tab. There is no certificate file to download.
This page is the short path. Connection strings covers each parameter in detail.
1. Take your credentials
- Open the service and press Connect, or select the Connect tab.
- Connection string gives you both hostnames and an example for each client. Your user and database are already in every example.
- Press Reveal password. The
psql, URI and.envexamples then hold your password too, and each one copies in a single click and works as pasted.
Every reveal is recorded in your audit log. That is deliberate, and the panel says so before you press it.
2. Choose an endpoint
Balta uses the standard PostgreSQL port, 5432, and every connection is encrypted. Your client must send the server name during the TLS handshake, which libpq 14 and newer and every current driver do. To also verify the certificate, turn on “Verify the certificate” on your language’s tab in the Connect page.
If your connection is refused, the error says why: an address not on the allowlist, a database that is temporarily unavailable, or a client that did not send the server name.
Both endpoints use that port and are told apart by hostname. Both names are your service's own and do not change for the life of the service.
| Endpoint | Hostname | Use it for |
|---|---|---|
| Pooled | db-example-pooler.fsn1.baltadb.net | Web and SaaS application traffic, serverless functions, anything with high connection churn. This is the default |
| Direct | db-example.fsn1.baltadb.net | LISTEN and NOTIFY, session advisory locks, session-level SET, WITH HOLD cursors, temporary tables across transactions |
These are the example names this documentation uses. The pooled name is the direct name with
-pooler on its first part. Yours are on the Connect tab.
Use pooled unless you need something on the right. Using both from the same application is normal: put your job-queue listener on direct and everything else on pooled.
Full compatibility detail is in pooled versus direct.
3. Connect
psql "postgresql://[email protected]/appdb?sslmode=require"There is no port in the string. It is 5432, the default, for both endpoints.
sslmode=require encrypts the connection, and it is the default line on the Connect tab because
every client we have run connects with it as given: libpq 14 and newer, psycopg, psycopg2,
node-postgres, postgres.js, Prisma, pgx, pgjdbc, Ruby's pg and Rails. It does not check the
certificate. Step 4 does.
Keep the password out of the connection string you commit. A password in a URL ends up in process
listings, shell history, container inspect output and log lines. Supply it through PGPASSWORD or
~/.pgpass instead, as the examples below do.
4. Verify the certificate as well
Your endpoint's certificate is issued by a public authority, so a client can also check that it is
talking to your database, with nothing to download and no path to fill in. Turn on Verify the
certificate on your language's tab, and the example becomes the form that checks the certificate
chain and that the hostname matches (verify-full).
| Client | What the switch gives |
|---|---|
psql and .env | sslmode=verify-full&sslrootcert=system. Needs libpq 16 or newer |
| Python, psycopg | sslmode="verify-full" with sslrootcert=certifi.where(), after pip install certifi |
Node, pg | sslmode=verify-full in the connection string |
Go, pgx | sslmode=verify-full |
Java, pgjdbc | sslmode=verify-full&sslfactory=org.postgresql.ssl.DefaultJavaSSLFactory |
We test each form three ways against a Balta database: it must connect, refuse a certificate from an authority the client does not trust, and refuse a trusted certificate issued for another name. Copy the form as given: a line that connects has not necessarily checked anything.
The URI and Ruby tabs have no switch. The URI is read by many drivers that disagree about
sslrootcert, and for Ruby's pg gem we found no form that verifies on every system without naming
a file on your computer. Both keep sslmode=require.
TLS and certificate verification covers the rest.
Client examples
export PGPASSWORD=<password>
psql "postgresql://[email protected]/appdb?sslmode=require"More languages, including Ruby on Rails, Django and JDBC, are on client examples.
What you will see
A successful psql connection opens a prompt on appdb, the database your service was created
with. \conninfo confirms which host you reached and that the connection is encrypted.
Troubleshooting
- Check you are using TLS. Non-TLS connections are refused, not downgraded.
- If you turned on verification, use the form the switch gives, unedited. A verification
failure is your client refusing a certificate it cannot check, not a plaintext fallback.
pgjdbc and node-postgres read
sslrootcertas a file path, and the switch's forms for them do not use it. - Check the hostname. The pooled endpoint is the name ending in
-pooler, the direct endpoint is the name without it, and both are on port 5432. Connect by name, not by IP address: an IP address sends no server name, and Balta needs the name to find your database.
Check the service's IP allowlist as well. An address that is not on it cannot open a connection: Balta refuses it before it reaches your database, with an error that names the address. A rule saved a moment ago takes a few seconds to reach the host. See IP allowlists for how the two allowlists differ.
A session variable your framework sets and reads back in a later transaction is the other common surprise. On the pooled endpoint it does not error: it reads the default, and the bug surfaces somewhere else entirely. Move that consumer to the direct endpoint. See pooled versus direct.
Message-by-message detail is on error messages.