All posts

Guides

4 min read

Connect Claude to Postgres in two minutes

Connect Claude to Postgres in two minutes

A step-by-step guide: create a read-only role, add Socket to Claude Desktop and ask your first question.

Tomás Ferreira

Developer relations

Article cover

This guide takes you from nothing to your first answer. You need Postgres 13 or newer and Claude Desktop.

1. Create a read-only role

Create a role with SELECT on the schemas you want to expose, and nothing else. Socket checks this on start and warns you if the role can write.

2. Add the server

Open your Claude Desktop config and add Socket with npx and your connection URL. Restart Claude and Socket appears under Connectors.

3. Ask a question

Try something you already know the answer to, like how many users signed up last week. Check the SQL in the audit log, then move on to the questions you do not know.

Create a free website with Framer, the website builder loved by startups, designers and agencies.