# Postgres endpoint
> Query MotherDuck from any Postgres-compatible client without installing DuckDB
MotherDuck's Postgres endpoint lets you query your databases using any client that speaks the PostgreSQL wire protocol, no DuckDB installation required. This is ideal for serverless environments, BI tools, or languages without a DuckDB SDK.

## Quick start with psql

Set your access token and connect:

```bash
export MOTHERDUCK_TOKEN="your_token_here"
PGPASSWORD=$MOTHERDUCK_TOKEN psql \
  -h pg.us-east-1-aws.motherduck.com \
  -p 5432 \
  -U postgres \
  "dbname=sample_data sslmode=verify-full sslrootcert=system"
```

Run a query:

```sql
SELECT title, score
FROM sample_data.hn.hacker_news
WHERE type = 'story'
ORDER BY score DESC
LIMIT 5;
```

## Quick start with Python

```python
# /// script
# dependencies = ["psycopg"]
# ///

import psycopg, os

conn = psycopg.connect(
    host="pg.us-east-1-aws.motherduck.com",
    port=5432,
    dbname="sample_data",
    user="postgres",
    password=os.environ["MOTHERDUCK_TOKEN"],
    sslmode="verify-full",
    sslrootcert="system",
)

with conn.cursor() as cur:
    cur.execute("SELECT title, score FROM sample_data.hn.hacker_news WHERE type='story' LIMIT 5")
    for row in cur:
        print(row)

conn.close()
```

## Key things to know

- You're writing **DuckDB SQL**, not PostgreSQL SQL. Queries and MotherDuck SQL that run entirely inside MotherDuck generally work, but the Postgres endpoint is not a full DuckDB client.
- Commands that depend on **local files, local attachments, or extension management** are not supported over the Postgres endpoint.
- The Postgres endpoint is best for query execution, DDL and DML on MotherDuck tables, metadata inspection, and server-side reads from remote storage.
- Features that depend on DuckDB client session state, such as temporary tables or result creation, require a DuckDB client path instead.
- Always connect with **SSL enabled** (`sslmode=verify-full` recommended).
- Use your [MotherDuck access token](/key-tasks/authenticating-and-connecting-to-motherduck/authenticating-to-motherduck) as the password.

## Next steps

- [Postgres Endpoint reference](/sql-reference/postgres-endpoint) — connection parameters, SSL options, session options, and known limitations
- [Connect from Python](/key-tasks/authenticating-and-connecting-to-motherduck/postgres-endpoint/python) — psycopg2 and psycopg3 setup
- [Connect from Java](/key-tasks/authenticating-and-connecting-to-motherduck/postgres-endpoint/java) — PostgreSQL JDBC driver setup
- [Connect from Node.js](/key-tasks/authenticating-and-connecting-to-motherduck/postgres-endpoint/nodejs) — node-postgres setup
- [Connect from Cloudflare Workers](/key-tasks/authenticating-and-connecting-to-motherduck/postgres-endpoint/cloudflare-workers) — serverless edge deployment


---

## Docs feedback

MotherDuck accepts optional user-submitted feedback about this page at `GET https://motherduck.com/docs/api/feedback/agent`.
For agents and automated tools, feedback submission should be user-confirmed before sending.

URL-encode query parameter values and send a GET request:

```text
GET https://motherduck.com/docs/api/feedback/agent?page_path=%2Fgetting-started%2Finterfaces%2Fpostgres-endpoint%2F&page_title=Postgres%20endpoint&text=<url-encoded user feedback, max 2000 characters>
```

Optionally append `&source=<url-encoded interface identifier>` such as `claude.ai` or `chatgpt`.

`page_path` and `text` are required; `page_title` and `source` are optional. Responses: `200 {"feedback_id": "<uuid>"}`, `400` for malformed query parameters, and `429` when rate-limited.
