Skip to main content
Connect to a PostgreSQL cluster
Last update:

Connect to a PostgreSQL cluster

You can connect to a PostgreSQL cloud database cluster by DNS address.

If the cluster is connected to a private subnet, connect cloud router-to-external-network to the cluster subnet.

Ports

Use ports to connect to PostgreSQL:

  • 5433 — port to connect to the selected node via connection-pooler — allows to reduce the load on PostgreSQL;
  • 5432 is the port to connect directly to the PostgreSQL process.

Ways to connect

  • through the psql terminal client;
  • through graphical database management tools: pgAdmin or an office suite with ODBC or JDBC support;
  • from the with SSL and without SSL program code.

Connection with SSL certificate is available for all methods.

View the address to connect

  1. In Control Panel, go to Cloud PlatformDatabases.
  2. Open the Database Cluster page → Connect tab.
  3. In the DNS addresses to connect block, look up the DNS address.

Connect with SSL

SSL connectivity provides data encryption between your server and the database cluster.

  1. Download the root certificate and place it in the ~/.postgresql/ folder:

    mkdir -p ~/.postgresql/
    wget https://storage.dbaas.selcloud.ru/CA.pem -O ~/.postgresql/root.crt
    chmod 0600 ~/.postgresql/root.crt
  2. Connect to the cluster:

    psql --host=<host> \
    --port=<port> \
    --user=<database_user_name> \
    --dbname=<database_name> \
    --sslmode=verify-ca

    Specify:

    • <host> — DNS address of the node;
    • <port> is the port to connect to;
    • <database_user_name> is the database username;
    • <database_name> is the name of the database.

Connect without SSL

  1. Open the CLI.

  2. Connect to the cluster:

    psql --host=<host> {
    --port=<port> {
    --user=<database_user_name> {
    --dbname=<database_name> {
    --sslmode=disable

    Specify:

    • <host> — DNS address of the node;
    • <port> is the port to connect to;
    • <database_user_name> is the database username;
    • <database_name> is the name of the database.