Connect to PostgreSQL
Retrieve account credentials and choose a private or external connection.
Retrieve connection details
- Open the database and select Connection in the sidebar.
- Under Connection, select a Connection account. Use an application account for normal workloads; see Manage database accounts.
- Connection details load automatically when you open this section or select another account.
- Choose the Project network or External TLS endpoint row and check its TLS status. Use the eye button at the end of its connection string to show or hide only that row, or copy the full string with its copy button. The URI includes the username, password and database name; separate fields are not shown.
Keep connection strings containing passwords in application secrets, not source control or shared logs.
Connect over the private network
Use the private endpoint from an application on the same server and project network. It is not reachable from the public internet. Use sslmode=require when database SSL is enabled; legacy databases without SSL require sslmode=disable.
With psql installed in that environment, replace the uppercase placeholders with values from the Console:
psql "host=PRIVATE_HOST port=5432 dbname=DATABASE_NAME user=APP_USERNAME sslmode=require" -WEnter the password at the prompt. Use the actual port shown by the Console if it differs.
Connect from outside the project
First enable external connections. Use the external hostname, not its IP address: the managed route requires TLS and SNI.
Database SSL must be enabled for external TLS connections. Enabling external connections alone does not enable database SSL.
Configure your client to verify the server certificate and hostname using an appropriate trusted CA. For a configured psql trust store:
psql "host=EXTERNAL_HOST port=5432 dbname=DATABASE_NAME user=APP_USERNAME sslmode=verify-full" -WThe Console's generated external URI uses sslmode=require. Certificate and hostname verification require the corresponding client settings, such as verify-full and a trusted root certificate.
Verify the connection
Run:
SELECT current_database(), current_user;Confirm the database and account match your selection. See the psql reference for client options and Troubleshooting for connection failures.