# Connect a Postgres client

Use PostgreSQL syntax to query Altertable from psql, DBeaver, pgAdmin, or a BI tool. For client-specific setup, see [Hex](/docs/integrations/hex.md) or [Metabase](/docs/integrations/metabase.md).

## Prerequisites

You need a PostgreSQL-compatible client, an Altertable catalog name, and [lakehouse credentials](/docs/administration/lakehouse-credentials.md) for the target environment.

## Connect

Set the host to `postgres.altertable.ai`, the port to `443`, and the database to your catalog name. Enable TLS and authenticate with your lakehouse username and password.

**psql**

```bash
PGSSLMODE=require psql -h postgres.altertable.ai -p 443 -U {{LAKEHOUSE_USERNAME}} your_database
```

**Python (psycopg2)**

```python
import psycopg2

conn = psycopg2.connect(
host="postgres.altertable.ai",
port=443,
database="your_database",
user="{{LAKEHOUSE_USERNAME}}",
password="{{LAKEHOUSE_PASSWORD}}",
sslmode="require"
)
```

## Run your first query

Run this in the connected client:

```sql
SELECT 1 AS ok;
```

The result should contain one row with an `ok` column equal to `1`.

### Postgres

```sql
-- Altertable speaks the Postgres wire protocol natively.
-- No SDK needed — any Postgres client works out of the box.

-- psql
psql "postgresql://{{LAKEHOUSE_USERNAME}}:{{LAKEHOUSE_PASSWORD}}@postgres.altertable.ai:443/my_db"
```

## Troubleshooting

### Unrecognized PostgreSQL function

The adapter translates PostgreSQL queries for the lakehouse. If a function call fails, check the function name and argument types. If the same call works in PostgreSQL, include the query and error message when [contacting support](/contact-us).

### TLS negotiation

The Postgres adapter supports standard PostgreSQL SSL negotiation on port 443.

If a connection times out before authentication, check whether your network performs TLS inspection on port 443. Some configurations, including Cloudflare Gateway TLS inspection, may reject PostgreSQL's plaintext SSLRequest preamble.

- Preferred: bypass TLS inspection for `postgres.altertable.ai`.
- For clients using libpq 17 or newer, add `sslnegotiation=direct` alongside `sslmode=require`.
- Clients without TLS-direct support, including Node `pg`, require the network bypass.