---
title: Connection strings
description: Understanding Lakebase connection strings, formats, and configuration
canonical_url: https://docs.databricks.com/gcp/en/oltp/projects/connection-strings
---

# Connection strings

A Lakebase connection string includes the role, hostname, and database name. For native Postgres password authentication, the connection string also includes the password. For OAuth authentication, you provide an OAuth token in place of a password. See [Obtain an OAuth token](https://docs.databricks.com/gcp/en/oltp/projects/authentication.md#u2m).

## Connection string format

**OAuth authentication:**

```
postgresql://your-email@example.com@ep-abc-123.databricks.com/databricks_postgres?sslmode=require
             ^                      ^                         ^
       role -|                      |- hostname               |- database
```

**Native Postgres password authentication:**

```
postgresql://role_name:password@ep-abc-123.databricks.com/databricks_postgres?sslmode=require
             ^         ^        ^                         ^
       role -|         |        |- hostname               |- database
                       |
                       |- password
```

> [!NOTE]
>
> The hostname includes the compute's **UID**, a system-generated identifier with an `ep-` prefix (for example, `ep-abc-123`). This is different from the compute name you provide when creating the compute. See [Compute identifiers](https://docs.databricks.com/gcp/en/oltp/projects/manage-computes.md#identifiers).

If you use connection pooling, the hostname format is different. See [Use connection pooling](https://docs.databricks.com/gcp/en/oltp/projects/connection-pooling.md).

## Connection string components

You can configure Postgres either with separate environment variables or with a single `DATABASE_URL`, depending on what your application or framework expects.

**To use individual components:**

```bash
PGHOST=ep-abc-123.databricks.com
PGDATABASE=databricks_postgres
PGUSER=role_name
PGPASSWORD=<your-password-or-oauth-token>
PGPORT=5432
```

**To use a single environment variable:**

```bash
DATABASE_URL="postgresql://role_name:password@ep-abc-123.databricks.com/databricks_postgres?sslmode=require"
```

## Connection security

* **SSL/TLS encryption**: Lakebase requires that all connections use SSL/TLS encryption. The `sslmode=require` parameter enforces this requirement. All connection strings provided in the Lakebase App include this parameter by default.

## Port

Lakebase uses the default Postgres port, **5432**.

## Network configuration

For public Postgres connections to Lakebase, allow outbound TCP traffic on port 5432 from your network. If your network filters destination IP addresses, allow all Lakebase IP addresses and ranges published for your region on the [IP addresses and domains page](https://docs.databricks.com/gcp/en/resources/ip-domain-region.md#inbound). Lakebase can use different addresses within those ranges.

## Next steps

* [Quickstart: Connect to your database](https://docs.databricks.com/gcp/en/oltp/projects/connect-overview.md)
* [Framework examples](https://docs.databricks.com/gcp/en/oltp/projects/framework-examples.md)
* [Learn about authentication](https://docs.databricks.com/gcp/en/oltp/projects/authentication.md)
