Connecting to self hosted supabase's postgres db (docker)

Took me a while to figure out how to access my Postgres db from self-hosted Supabase (for chat memory on n8n). I couldn’t find a direct solution for this topic, so I thought this might help others having the same issue.

This guide from Supabase explains how to connect:

psql 'postgres://postgres.your-tenant-id:your-super-secret-and-long-postgres-password@localhost:6543/postgres'

So the trick is to create the credentials for Postgres on n8n using port 6543 (for pooled transactional connections), and for the User field, you have to add both your username and tenant_id, joined with a “.”, like the example below:
username.tenant_id

So, if using the default username and set tenant_id as 1234, your User would be:
postgres.1234

(You should have set this tenant id on the .env file during the instalation of supabase.)

Host would be just the IP of your installation and password is what you have also set on the .env file.

Thats is all… Hope it helps!

3 Likes

Thank you for this hint!

Hello, I’m trying to create a postgress credential on N8N to access the supabase without success. The test information is below. How would I configure the node please?

POSTGRES_PASSWORD=your-super-secret-and-long-postgres-password
POSTGRES_HOST=db
POSTGRES_DB=postgres
POSTGRES_PORT=5432

default user is postgres

POOLER_PROXY_PORT_TRANSACTION=6543
POOLER_DEFAULT_POOL_SIZE=20
POOLER_MAX_CLIENT_CONN=100
POOLER_TENANT_ID=1357

HI. I have a self-hosted supabase setup with coolify. No tenant_id was specified in the env. Can you show a sample of your config?

many thanks. It help me.