Identify both ends of the connection
On Bothosting, connect to the PostgreSQL host and port shown in Connection with the database name app and user app. The owner downloads two files there. client.pem identifies your client and contains its private key. server-ca.pem lets the client verify the server. Keep the client file readable only by the account running your application.
Copy the exact hostname from the database deployment. A website’s HTTPS address belongs to its HTTP service. Even a raw IP that reaches the database port can fail hostname verification because the server certificate names the database host.
Test a read before configuring the framework
On the machine that will connect, set DB_HOST and DB_PORT to the displayed values. Run this from the private directory containing the two downloaded files. It opens one session, reads the current database and role, and exits.
chmod 600 client.pem
PGSSLMODE=verify-full PGSSLROOTCERT=server-ca.pem PGSSLCERT=client.pem PGSSLKEY=client.pem \
psql -X -h "$DB_HOST" -p "$DB_PORT" -U app -d app \
-c "SELECT current_database(), current_user"Expect app in both columns. Configure the application driver with the same host, port, trust and identity. Driver option names vary. PostgreSQL explains the trust and hostname checks in its libpq SSL documentation.
Use the first failure to choose the next check
If the connection times out, check the engine is running and the address and port are correct. For a hostname mismatch, compare the host passed to the driver with Connection. If the server rejects the client, check that the client identity came from this deployment and is still current. If psql connects but the app fails, compare the two file paths, process users and driver settings. Use the identity replacement procedure when the identity needs rotation.