Skip to main content

Connect to a PostgreSQL PGVector cluster

You can connect to a PostgreSQL PGVector cluster:

  • via the psql console client;
  • via database management GUI tools: pgAdmin or an office suite with ODBC or JDBC support;
  • from application code.

All methods support connecting with SSL and without SSL.

To connect, use the port and address.

Connection ports

To connect to PostgreSQL PGVector, use the following ports:

  • 5433 — port for connecting to the selected node via the connection pooler — reduces the load on PostgreSQL PGVector;
  • 5432 — port for connecting directly to the PostgreSQL PGVector process.

Connection addresses

You can select a connection address based on one of the following scenarios:

You can view the connection address in the Control Panel.

Connecting to a cluster in a public subnet

If the cluster is in a public subnet, you can connect to the nodes using a DNS address or an IP address from the public subnet.

We recommend connecting via a DNS address. The cluster uses the master discovery mechanism for DNS addresses: the address is bound to the node role rather than the node itself. If the master becomes unavailable, one of the replicas becomes the new master, and the address moves to the new node along with the role.

When connecting via an IP address from a public subnet, the master discovery mechanism is not used. If one of the replicas becomes the new master, the master's IP address will change, and the connection using the old IP address will stop working.

Connecting from a private subnet to a cluster in a private subnet

If you are connecting from a private subnet to a cluster in a private subnet, you can use a DNS address or a private IP address.

We recommend connecting via a DNS address. The cluster uses the master discovery mechanism for DNS addresses: the address is bound to the node role rather than the node itself. If the master becomes unavailable, one of the replicas becomes the new master, and the address moves to the new node along with the role.

When connecting via a private IP address, the master discovery mechanism is not used. If one of the replicas becomes the new master, the master's IP address will change, and the connection using the old IP address will stop working.

To connect from another private subnet, first connect both private subnets to a cloud router.

Connecting from the Internet to a cluster in a private subnet

If you connect to a cluster in a private subnet from the internet, you can only use a public floating IP address (Floating IP).

For public floating IP addresses (Floating IPs), the master discovery mechanism is used — the address is bound to the node's role, not to the node itself. If the master becomes unavailable, one of the replicas becomes the new master, and the address moves to the new node along with the role.

View the connection address

  1. In the Control panel, in the top menu, click Products and select Cloud Databases.
  2. Open the Active tab.
  3. Go to the database cluster page → Connection tab.
  4. In the Connection addresses block, check the address.

Connect with SSL

Connecting using TLS (SSL) encryption provides a secure connection between your server and the database cluster.

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

    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> \
    dbname=<database_name> \
    user=<database_user_name> \
    sslmode=verify-ca"

    Specify:

    • <host> — DNS address or public IP address (Floating IP) of the node;
    • <port> — connection port;
    • <database_name> — database name;
    • <database_user_name> — database username.

Connect without SSL

  1. Open the CLI.

  2. Connect to the cluster:

    psql "host=<host> \
    port=<port> \
    dbname=<database_name> \
    user=<database_user_name> \
    sslmode=disable"

    Specify:

    • <host> — DNS address or public IP address (Floating IP) of the node;
    • <port> — connection port;
    • <database_name> — database name;
    • <database_user_name> — database username.