Home » n8n» Connect Supabase to n8n with Docker and Postgres

How to connect supabase to n8n?

Connect Supabase to n8n by adding your Supabase credentials to n8n and using the Postgres node for direct database queries or the HTTP Request node for the REST API. This guide gives step-by-step commands and clear examples for a Docker setup.

How to connect supabase to n8n: What You Need

  • A Supabase project (hosted or local).
  • An n8n instance running in Docker.
  • Supabase URL and keys (anon or service_role).
  • Database connection string for Postgres access.
  • n8n credentials stored securely.

Step 1: Start n8n with Docker

Run n8n in Docker for testing. The command below starts n8n with basic auth and persistent storage.

docker run -it --rm \
  --name n8n \
  -p 5678:5678 \
  -e N8N_BASIC_AUTH_ACTIVE=true \
  -e N8N_BASIC_AUTH_USER=user \
  -e N8N_BASIC_AUTH_PASSWORD=pass123 \
  -v ~/.n8n:/home/node/.n8n \
  n8nio/n8n:latest

Open http://localhost:5678 and log in with the credentials above.

Step 2: Get Supabase keys and DB info

Find your Supabase details in the Supabase dashboard. You need:

  • Project URL (e.g., https://projectref.supabase.co).
  • Anon or service_role API key.
  • Database host, port (5432), user, database name, and password.

Test the Postgres connection from your terminal before adding it to n8n.

PGPASSWORD="your_db_password" psql "postgresql://postgres:your_db_password@db.host.supabase.co:5432/postgres?sslmode=require"

Step 3: Connect using the Postgres node in n8n

Use the Postgres node for direct SQL queries. It is faster and supports transactions.

1. Create new credentials in n8n: Host, Port, Database, User, Password, SSL = true.

2. Add a Postgres node to your workflow and select the credentials.

3. Run a simple query to verify.

SELECT id, title FROM public.notes LIMIT 5;

Step 4: Connect using the HTTP Request node to Supabase REST

Use the HTTP Request node to call Supabase REST endpoints when you prefer the API layer.

Example curl to list rows from a table named notes:

curl -X GET "https://PROJECT_REF.supabase.co/rest/v1/notes" \
  -H "apikey: YOUR_ANON_KEY" \
  -H "Authorization: Bearer YOUR_ANON_KEY" \
  -H "Accept: application/json"

In n8n, create an HTTP Request node. Set method to GET, paste the URL, and add headers for apikey and Authorization.

Step 5: Workflow example and numbered logic

Example logic for a simple automation:

  1. Trigger: Webhook node receives data.
  2. Action: HTTP Request node inserts row via Supabase REST.
  3. Verify: Postgres node queries and confirms the insert.
  4. Notify: Send result via Email or Slack node.

Each step maps to a node. Test each node independently before chaining them.

Update

Keep n8n and Supabase components updated. For Docker, pull the latest images regularly.

docker pull n8nio/n8n:latest
# For a hosted Supabase, follow the Supabase dashboard updates.

Backup your n8n workflows and Supabase data before major upgrades.

Security

Store keys in n8n credentials, not as plain text in nodes. Use SSL for Postgres connections.

  • Use the least-privilege Supabase key for automation.
  • Avoid embedding service_role keys in public workflows.
  • Rotate keys and use environment secrets for Docker.
# Example: run n8n with an env file reference
docker run -it --rm --env-file ./n8n.env -p 5678:5678 -v ~/.n8n:/home/node/.n8n n8nio/n8n:latest

Done

You can now connect Supabase to n8n. Use Postgres for direct DB tasks and HTTP for REST operations. Test, secure, and update regularly.


If you need a sample workflow file or help with a specific query, export your n8n workflow and share the details for tailored steps.

Neil
Written by Neil

Neil is a true n8n geek who lives and breathes workflow automation. He dives deep into nodes, triggers, webhooks, custom logic, and self-hosting setups, sharing everything he learns about n8n on AutomationCompare.com. As part of a broader team of automation specialists, Neil focuses purely on mastering n8n and helping others unlock its full potential.

Keep Reading

Scroll to Top