> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-sync-clickhouse-operator-docs-7e82242.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Connecting to Managed Postgres

> Connection strings, PgBouncer connection pooling, and TLS configuration for ClickHouse Managed Postgres

export const Image = ({img, alt, size}) => {
  return <Frame>
      <img src={img} alt={alt} />
    </Frame>;
};

export const PrivatePreviewBadge = () => {
  return <div className="privatePreviewBadge">
            <div className="privatePreviewIcon">
            <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
                <path d="M5.33301 6.66667V4.66667V4.66667C5.33301 3.194 6.52701 2 7.99967 2V2C9.47234 2 10.6663 3.194 10.6663 4.66667V4.66667V6.66667" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" />
                <path d="M8.00033 9.33337V11.3334" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" />
                <path fillRule="evenodd" clipRule="evenodd" d="M11.333 14H4.66634C3.92967 14 3.33301 13.4033 3.33301 12.6666V7.99996C3.33301 7.26329 3.92967 6.66663 4.66634 6.66663H11.333C12.0697 6.66663 12.6663 7.26329 12.6663 7.99996V12.6666C12.6663 13.4033 12.0697 14 11.333 14Z" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" />
            </svg>
        </div>
            {'Private preview in ClickHouse Cloud'}
        </div>;
};

<h2 id="accessing-connection-details">
  Accessing connection details
</h2>

To connect your applications to Managed Postgres, navigate to the **Connect** view in the left sidebar of your instance.

<Image img="https://mintcdn.com/private-7c7dfe99-sync-clickhouse-operator-docs-7e82242/sksml5zVfCt3OYQp/images/managed-postgres/connect-button.png?fit=max&auto=format&n=sksml5zVfCt3OYQp&q=85&s=ca4c1d4b3d4edff10280a9516ba4d65f" alt="Click Connect in the left sidebar to view connection details" size="md" border width="1378" height="1148" data-path="images/managed-postgres/connect-button.png" />

Clicking **Connect** opens a modal displaying your connection credentials and connection strings in multiple formats.

<Image img="https://mintcdn.com/private-7c7dfe99-sync-clickhouse-operator-docs-7e82242/sksml5zVfCt3OYQp/images/managed-postgres/connect-modal.png?fit=max&auto=format&n=sksml5zVfCt3OYQp&q=85&s=49eef8d0a46506b0e51f5ea59cd3e875" alt="Connection modal showing credentials and connection string formats" size="md" border width="1910" height="1728" data-path="images/managed-postgres/connect-modal.png" />

The connection modal displays the following information:

* **Username**: The database user (default: `postgres`)
* **Password**: Your database password (masked by default, click the eye icon to reveal)
* **Server**: The hostname for your Managed Postgres instance
* **Port**: The PostgreSQL port (default: `5432`)

Managed Postgres provides superuser access to your database. Use these credentials to connect as a superuser, which allows you to create additional users and manage database objects.

<h2 id="connection-string">
  Connection string formats
</h2>

The **Connect via** tabs provide your connection string in multiple formats to match your application's requirements:

| Format   | Description                                                                                     |
| -------- | ----------------------------------------------------------------------------------------------- |
| **url**  | Standard connection URL in the format `postgresql://<USER>:<PASSWORD>@<HOST>:<PORT>/<DATABASE>` |
| **psql** | Ready-to-use command for connecting via the psql command line tool                              |
| **env**  | Environment variables for libpq-based clients                                                   |
| **yaml** | YAML formatted configuration                                                                    |
| **jdbc** | JDBC connection string for Java applications                                                    |

For security reasons, the password in connection strings is masked by default. Click the copy icon next to any field or connection string to copy it directly to your clipboard.

<h2 id="pgbouncer">
  PgBouncer connection pooling
</h2>

Managed Postgres includes a bundled [PgBouncer](https://www.pgbouncer.org/) instance for server-side connection pooling. PgBouncer helps improve connection management, performance, and resource utilization, especially for applications that:

* Open many concurrent connections
* Frequently create and close connections
* Use serverless or ephemeral compute environments

To use connection pooling, click the **via PgBouncer** toggle at the top of the connection modal. The connection details will update to route your connections through the connection pooler instead of directly to PostgreSQL.

<Tip>
  **When to use PgBouncer**

  Use PgBouncer when your application opens many short-lived connections. For long-running connections or applications that use PostgreSQL features incompatible with connection pooling (like prepared statements across transactions), connect directly.

  Moving data to ClickHouse using ClickPipes isn't supported via PgBouncer.
</Tip>

<h2 id="tls">
  TLS configuration
</h2>

All Managed Postgres instances are secured with TLS. The minimum supported version is **TLS 1.3**.

<h3 id="quick-connection">
  Quick connection (TLS encrypted)
</h3>

By default, connections use TLS encryption without certificate verification:

```bash theme={null}
psql 'postgresql://postgres:PASSWORD@your-instance.pg.clickhouse.cloud:5432/postgres'
```

<h3 id="verified-tls">
  Verified TLS connection (recommended for production)
</h3>

For production workloads, we recommend connecting with verified TLS to ensure you're communicating with the correct server. To do this, download the CA certificate bundle from the **Settings** tab and add it to your database client's trusted certificates.

<Image img="https://mintcdn.com/private-7c7dfe99-sync-clickhouse-operator-docs-7e82242/iWpSV4kCU4b95KM3/images/managed-postgres/tls-ca-bundle.png?fit=max&auto=format&n=iWpSV4kCU4b95KM3&q=85&s=ca5d5810227d26b120419f7ca4cbadd9" alt="Download CA Certificate from the Settings tab" size="md" border width="3244" height="2028" data-path="images/managed-postgres/tls-ca-bundle.png" />

The CA certificate is unique to your Managed Postgres instance and won't work with other instances.

To connect with a verified TLS connection, add `sslmode=verify-full` and the path to your downloaded certificate:

```bash theme={null}
psql 'postgresql://postgres:PASSWORD@your-instance.pg.clickhouse.cloud:5432/postgres?sslmode=verify-full&sslrootcert=/path/to/ca-certificate.pem'
```
