How to Connect n8n to Supabase: Store and Query Data (2025)
Supabase gives you a hosted Postgres database with a REST API, auth, and storage on top. For n8n, it's the perfect place to persist data your workflows produce — leads, logs, embeddings, application state — without standing up your own database server.
This guide shows two ways to connect n8n to Supabase: the native Supabase node for quick CRUD, and the Postgres node for full SQL power. We'll also cover using pgvector for AI/RAG workflows.
When to use the Supabase node vs the Postgres node
Both talk to the same database, but they suit different jobs:
- Supabase node — simplest for insert/update/get/delete on a single table. Uses the Supabase REST API and your project's API key. Great for app-style CRUD.
- Postgres node — connects directly to the database and runs arbitrary SQL: joins, aggregations, upserts, transactions, and pgvector similarity search. Choose this for anything analytical or vector-based.
Step 1 — Gather your Supabase credentials
In your Supabase dashboard, open Project Settings → API. You'll need:
- Project URL — like
https://xxxx.supabase.co(for the Supabase node). - service_role key — for server-side writes that bypass Row Level Security (keep it secret).
- Database connection string — under Project Settings → Database, for the Postgres node (host, port 5432 or the 6543 pooler, database, user, password).
Step 2 — Connect with the Supabase node
Add a Supabase node, create a credential, and paste your Project URL and service_role key. Now you can pick a table and an operation. For example, to log a lead: choose Create Row, select your leads table, and map fields from earlier nodes. Because the service_role key bypasses RLS, use it only in trusted server-side workflows — never expose it to a browser.
Step 3 — Connect with the Postgres node
Add a Postgres node and create a credential from your connection string. For serverless/pooled connections, use the connection pooler host on port 6543 and set SSL to Require. Test the credential; n8n runs a lightweight query to confirm. Now you can run any SQL: INSERT ... ON CONFLICT DO UPDATE for upserts, multi-table joins to build a report, or a parameterized query using expressions like {{ $json.email }}. Always parameterize inputs to avoid SQL injection.
Want a RAG chatbot without touching a line of code?
This template ingests your docs into a vector store and answers questions over them — a working blueprint you can adapt to Supabase pgvector.
Step 4 — Use pgvector for RAG and semantic search
Supabase supports the pgvector extension, which turns Postgres into a vector database. The pattern for an AI knowledge base:
- Enable the extension:
create extension vector;and create a table with avector(1536)column for embeddings. - In n8n, generate embeddings with the OpenAI/Embeddings node for each chunk of your documents.
- Store the chunk text and its embedding with the Postgres node.
- At query time, embed the user's question and run a similarity query:
ORDER BY embedding <=> $1 LIMIT 5. - Feed the top chunks to an LLM node as context and return the answer.
This is exactly how retrieval-augmented chatbots work — Supabase just gives you the vector store for free alongside your relational data.
Troubleshooting the connection
- SSL error — set SSL to Require in the Postgres credential; Supabase enforces TLS.
- Too many connections — use the pooler host (port 6543) instead of the direct 5432 connection for high-frequency workflows.
- Row not inserting via Supabase node — RLS is blocking it; confirm you're using the service_role key, not the anon key.
Frequently asked questions
Is Supabase free to use with n8n?
Supabase has a generous free tier that's plenty for most automations. n8n's Supabase and Postgres nodes are free in core.
Should I use the anon key or service_role key?
For server-side n8n workflows, use service_role for full access. Reserve the anon key for client apps governed by Row Level Security.
Can I run a full RAG app on Supabase alone?
Yes — pgvector handles embeddings and similarity search, so you can keep documents, metadata, and vectors in one database instead of adding a separate vector store.
Ready to automate this?
Skip the build. The RAG Chatbot on Google Drive Docs (Gemini + Qdrant + Telegram) template is ready to import into n8n — plug in your credentials and it runs. One-time purchase, yours forever, no subscription.