> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-8a08bda2.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 galaxyOnClick = eventName => () => {
  try {
    if (typeof window !== "undefined" && window.galaxy && eventName) {
      window.galaxy.track(eventName, {
        interaction: "click"
      });
    }
  } catch (e) {}
};

export const BetaBadge = ({link, galaxyTrack, galaxyEvent}) => {
  if (link) {
    return <a href={link} target="_blank" rel="noopener noreferrer" className="betaBadge" onClick={galaxyTrack && galaxyEvent ? galaxyOnClick(galaxyEvent) : undefined}>
                <Icon />
                <span>Beta</span>
            </a>;
  }
  return <div className="betaBadge">
            <Icon />
            <span>
                Beta feature. 
                <u>
                    <a href="/docs/beta-and-experimental-features#beta-features">
                        Learn more.
                    </a>
                </u>
            </span>
        </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-mintlify-8a08bda2/1Ag2q2dX2WMxuS9G/images/managed-postgres/connect-button.png?fit=max&auto=format&n=1Ag2q2dX2WMxuS9G&q=85&s=76d15ac07185aeac008badafd352fa13" 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-mintlify-8a08bda2/1Ag2q2dX2WMxuS9G/images/managed-postgres/connect-modal.png?fit=max&auto=format&n=1Ag2q2dX2WMxuS9G&q=85&s=3b804430de4f44a121824a96618d78a8" 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-mintlify-8a08bda2/1Ag2q2dX2WMxuS9G/images/managed-postgres/tls-ca-bundle.png?fit=max&auto=format&n=1Ag2q2dX2WMxuS9G&q=85&s=1e6ac6b2725905455d48d3d3ac8321ae" 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'
```
