Yandex Cloud
Search
Contact UsGet started
  • Pricing
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • AI for business
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
  • Pricing
  • Customer Stories
  • Documentation
  • Blog
© 2025 Direct Cursus Technology L.L.C.
Yandex Managed Service for PostgreSQL
  • Getting started
  • Access management
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Public materials
  • Release notes

In this article:

  • Getting started
  • Create a cluster
  • Connect to the DB
  • Send your requests to the database
  • What's next

Getting started with Managed Service for PostgreSQL

Written by
Yandex Cloud
Improved by
Danila N.
Updated at November 14, 2025
  • Getting started
  • Create a cluster
  • Connect to the DB
  • Send your requests to the database
  • What's next

Managed Service for PostgreSQL helps you create and maintain PostgreSQL clusters in the Yandex Cloud infrastructure.

To get started:

  1. Create a DB cluster.
  2. Connect to the DB.
  3. Send your requests to the database.

Getting startedGetting started

  1. Navigate to the management console and log in to Yandex Cloud or sign up if not signed up yet.

  2. If you do not have a folder yet, create one:

    1. In the management console, select the appropriate cloud from the list on the left.

    2. At the top right, click Create folder.

    3. Give your folder a name. The naming requirements are as follows:

      • It must be from 2 to 63 characters long.
      • It can only contain lowercase Latin letters, numbers, and hyphens.
      • It must start with a letter and cannot end with a hyphen.
    4. Optionally, specify the description for your folder.

    5. Select Create a default network. This will create a network with subnets in each availability zone. Within this network, you will also have a default security group, within which all network traffic will be allowed.

    6. Click Create.

  3. Assign the vpc.user and managed-postgresql.editor roles for the folder to your Yandex Cloud account. to be able to create a cluster.

    Note

    If you are unable to manage roles, contact your cloud or organization administrator.

  4. You can connect to DB clusters from both inside and outside Yandex Cloud:

    • To connect from inside Yandex Cloud, create a Linux VM in the same network as the DB cluster.

    • To connect to the cluster from the internet, request public access to hosts when creating the cluster.

    Note

    The next step implies connecting to the cluster from a VM. If your plan is to connect to the cluster from the internet, proceed to creating a cluster.

  5. Connect to the VM over SSH.

Create a clusterCreate a cluster

  1. In the management console, select the folder where you want to create a DB cluster.

  2. Select Managed Service for PostgreSQL.

  3. Click Create cluster.

  4. In the Cluster name field, enter a name for the cluster.

  5. Select the PRODUCTION environment.

  6. Select the PostgreSQL version.

  7. Select the host class. Host class determines the technical specifications of the VMs the cluster hosts will be deployed on.

  8. Under Storage:

    1. Select the disk type.
    2. Set the storage size.
  9. Under Database:

    1. Specify the DB name. It must be unique within the folder.
    2. Specify the user name of the DB owner.
    3. Enter your password or generate one using Connection Manager.
  10. Under Network settings:

    1. Select the cloud network you created before you started out.
    2. Select the default security group or create a new one.
  11. Under Hosts, specify the availability zones and subnets for the hosts that will be created together with the cluster.

    If you plan to connect to the cluster from the internet, enable Public access for the hosts.

  12. Click Create cluster.

  13. Wait until the cluster is ready to work: its status will change to Running, and its state to Alive. To check its state, hover over the cluster status in the Availability column.

Connect to the DBConnect to the DB

Warning

If you are using security groups for a cloud network, configure them to enable all relevant traffic between the cluster and the connecting host.

To connect to the database:

Linux (Bash)/macOS (Zsh)
Windows (PowerShell)
  1. Get an SSL certificate:

    mkdir -p ~/.postgresql && \
    wget "https://storage.yandexcloud.net/cloud-certs/CA.pem" \
            --output-document ~/.postgresql/root.crt && \
    chmod 0655 ~/.postgresql/root.crt
    

    The certificate will be saved to the ~/.postgresql/root.crt file.

  2. Install the required dependencies and the PostgreSQL client:

    sudo apt update && sudo apt install -y postgresql-client
    
  3. Connect to the database:

    psql "host=c-<cluster_ID>.rw.mdb.yandexcloud.net \
          port=6432 \
          sslmode=verify-full \
          dbname=<DB_name> \
          user=<user_name> \
          target_session_attrs=read-write"
    

    You can get the cluster ID with the list of clusters in the folder.

  1. Install the same PostgreSQL for Windows version that is used in the cluster. Select the Command Line Tools install only.

  2. Get an SSL certificate:

    mkdir $HOME\.postgresql; curl.exe -o $HOME\.postgresql\root.crt https://storage.yandexcloud.net/cloud-certs/CA.pem
    

    The certificate will be saved to the $HOME\.postgresql\root.crt file.

  3. Set the environment variables for the connection:

    $Env:PGSSLMODE="verify-full"; $Env:PGTARGETSESSIONATTRS="read-write"
    
  4. Connect to the database:

    & "C:\Program Files\PostgreSQL\<PostgreSQL_major_version>\bin\psql.exe" `
        --host=c-<cluster_ID>.rw.mdb.yandexcloud.net `
        --port=6432 `
        --username=<username> `
        <DB_name>
    

    You can get the cluster ID with the list of clusters in the folder.

Send your requests to the databaseSend your requests to the database

  1. Create a table named customers in the cluster database:

    CREATE TABLE IF NOT EXISTS customers (
        name VARCHAR,
        phone VARCHAR,
        acctbal NUMERIC
    );
    
  2. Populate the table with data:

    INSERT INTO customers (name, phone, acctbal) VALUES
        ('John Doe', '123-45-67', 1500.50),
        ('Mary Johnson', '222-33-44', 3250.00),
        ('David Smith', '555-66-77', -50.75),
        ('Anna Davis', '111-22-33', 0.00),
        ('Paul Brown', '444-55-66', 780.30);
    
  3. Get the number of rows in the table:

    SELECT COUNT(*) FROM customers;
    

    Result:

    count
    -------
        5
    (1 row)
    

What's nextWhat's next

  • Transfer data to the cluster database.
  • Read about the service concepts.
  • Learn more about creating a cluster and connecting to a database.
  • Check out our user tutorials.
  • Check questions and answers.

Was the article helpful?

Next
All guides
© 2025 Direct Cursus Technology L.L.C.