Skip to main content
To work with a database in a Managed Service for PostgreSQL cluster, you need to connect to it.

Prerequisites

  1. Create a cluster and securely store the password you specified during creation.
  2. To connect to a database, install psql, a PostgreSQL command line client:
    brew install libpq
    echo 'export PATH="/opt/homebrew/opt/libpq/bin:$PATH"' >> ~/.zshrc
    
    After that, restart the terminal.
  3. To secure connections to databases, install the Nebius AI Cloud certificate:
    mkdir -p ~/.postgresql \
    curl "https://storage.eu-north1.nebius.cloud/msp-certs/ca.pem" \
       -o ~/.postgresql/root.crt \
    chmod 0600 ~/.postgresql/root.crt
    
    This command creates the .postgresql folder, downloads the certificate into it and then sets the access rights to the certificate file.

How to connect to a database

Go to the web console and get the connection command with all data filled in for your cluster:
  1. In the sidebar, go to https://mintcdn.com/nebius-ai-cloud/1Ha0sWR6e1mnIaHS/_assets/sidebar/storage.svg?fit=max&auto=format&n=1Ha0sWR6e1mnIaHS&q=85&s=0a2dad6b48aea10e85f6f3e2343aee26 Storage → PostgreSQL.
  2. Click your cluster.
  3. Click How to connect.
  4. Copy the connection command from the window that opens.
Enter this command in the terminal. You will be asked for the password you specified when creating the cluster.

Details of the connection command

The connection command that you copy from the web console looks like this:
psql "host=<cluster_endpoint> \
  port=5432 \
  sslmode=verify-full \
  dbname=<DB_name> \
  user=<username>" 
It contains the following parameters:
  • <DB_name>: Default database name that you specified when creating the cluster. If you created another database in this cluster, you can use its name instead.
  • <username>: The username you specified when creating the cluster.
    Once you create other databases and users, you can use their names instead.
  • <cluster_endpoint>: Depends on where you are connecting from:
    • To connect from the internet, use the public cluster endpoint. You can connect from the internet only if you enabled public access to the cluster when you created it.
    • To connect from other Nebius AI Cloud resources, use the private cluster endpoint.
To get the endpoints:
  1. In the sidebar, go to https://mintcdn.com/nebius-ai-cloud/1Ha0sWR6e1mnIaHS/_assets/sidebar/storage.svg?fit=max&auto=format&n=1Ha0sWR6e1mnIaHS&q=85&s=0a2dad6b48aea10e85f6f3e2343aee26 Storage → PostgreSQL.
  2. Click your cluster.
  3. Click Copy endpoint URL and select Public RW endpoint URL to copy the public cluster endpoint, or Private RW endpoint URL to copy the private cluster endpoint.

Postgres, PostgreSQL and the Slonik Logo are trademarks or registered trademarks of the PostgreSQL Community Association of Canada, and used with their permission.