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.

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.

If you use connection pooling, the hostname format is different. See Use connection pooling.

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:

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:

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. Lakebase can use different addresses within those ranges.

Next steps