---
title: "n8n Supabase Postgres Connection: Pooler, IPv6 and SSL"
description: "Connect self-hosted n8n to Supabase Postgres: session pooler vs direct IPv6, the postgres.<ref> username, SSL, a least-privilege role, and exact error fixes."
canonical: "https://www.razi.pro/blog/n8n-supabase-postgres-connection"
date: "2026-12-03"
tags: ["n8n", "Supabase", "PostgreSQL", "Self-Hosting", "Troubleshooting"]
source: "razi.pro"
---

# n8n Supabase Postgres Connection: Pooler, IPv6 and SSL

Before you read on: your n8n credential has the right host, the right password and the right port, and Supabase still says the user does not exist. What is wrong?

The answer, in my case, was one digit in the hostname. I will get to it. First, the short version, because you probably arrived here with a red error and a workflow that will not save.

**If you self-host n8n on an ordinary VPS, use the shared pooler in session mode:** host `aws--.pooler.supabase.com`, port `5432`, user `.`, database `postgres`, SSL on. Copy the host from the dashboard; do not guess it.

The rest of this post explains why, what each error means, and how to give n8n a role that cannot drop your tables.

---

## Why the obvious host fails

The Supabase dashboard shows a direct connection first, and it looks like the natural choice: `db..supabase.co:5432`.

Here is the line in [Supabase's connection guide](https://supabase.com/docs/guides/database/connecting-to-postgres) that explains most of the n8n community threads on this subject: direct connections are on IPv6, or on IPv4 if the project has the IPv4 add-on.

Most cheap VPSes, most home networks and a lot of Docker setups only speak IPv4 outbound. Docker in particular does not give containers IPv6 unless you configure it. So n8n resolves the direct host, gets an IPv6 address or nothing at all, and cannot reach it. Nothing is wrong with your password. The packets have nowhere to go.

You have three ways out:

| Option | What it is | When to pick it |
|---|---|---|
| Direct connection | `db..supabase.co:5432`, no pooler in the path | Your n8n host really has working IPv6 |
| IPv4 add-on | A paid add-on that makes the direct connection reachable over IPv4 | You want the direct path and your host is IPv4-only |
| Shared pooler, session mode | `aws--.pooler.supabase.com:5432`, IPv4 | Everyone else, including me |

The connection guide says this directly: a persistent backend on IPv6 or with the add-on can use the direct connection; on an IPv4-only network without the add-on, use the shared pooler in session mode.

One detail about the add-on, also from the guide: it swaps the project's IPv6 (AAAA) DNS record for an IPv4 (A) record. It is a swap, not an addition. I have not tried the add-on, so I cannot tell you more than the docs do.

---

## The pooler, field by field

The shared pooler is Supavisor. It sits between n8n and Postgres and it is reachable over IPv4. It has two modes on the same host, picked by port.

| | Session mode | Transaction mode |
|---|---|---|
| Port | `5432` | `6543` |
| One server connection per | client session | transaction |
| Prepared statements | Supported | Not supported |
| Good for | Long-lived servers like n8n | Serverless functions with many short connections |

For n8n, use **session mode on port 5432**. n8n is a long-running process with its own connection pool, which is exactly the client session mode is built for. Transaction mode exists for serverless code that opens hundreds of short connections; that is not your situation.

The prepared-statement row matters. The connection guide says the shared pooler does not support prepared statements in transaction mode and tells you to turn them off in your client library. The n8n Postgres credential has no setting for that, so port 6543 is a door you do not need to open. (I confirmed that both ports were reachable from my VPS when I set this up. I only run workflows on 5432.)

Now the n8n credential itself. The fields below are the ones listed in the [n8n Postgres credential docs](https://docs.n8n.io/integrations/builtin/credentials/postgres/):

| n8n field | Value for Supabase |
|---|---|
| Host | `aws--.pooler.supabase.com`, copied from the dashboard |
| Database | `postgres` |
| User | `.`, for example `postgres.` |
| Password | That role's password |
| Maximum Number of Connections | Default is 100. Lower it on a small project (see below) |
| Ignore SSL Issues (Insecure) | Off |
| SSL | `Require` |
| Port | `5432` |
| SSH Tunnel | Off |

Two fields deserve a closer look.

**The user has a dot in it.** The pooler serves many projects from one hostname, so it needs to know which project you mean. It reads that from the username: `postgres.`, not plain `postgres`. This holds for any role you create yourself, too. My role is called `n8n_writer`, and in n8n the User field says `n8n_writer.`.

**The host has a number in it.** That is the trap from the top of this post.

> **A warning worth the detour.**
> The pooler host starts with `aws--`, and `N` is not always 0. My project lives on `aws-1`. I first typed `aws-0` with the right region, because that is what most examples on the internet show. The hostname resolved. The TLS handshake worked. Postgres answered, and the answer was a `FATAL` saying the tenant or user was not found. That reads exactly like a wrong password or a wrong username, so I spent my time checking those. The fix is to copy the host from the **Connect** panel in the Supabase dashboard instead of building it by hand. It cost me an evening; it should cost you a paste.

---

## SSL: what Require does and what it does not

Supabase does not enforce SSL by default. The [SSL enforcement page](https://supabase.com/docs/guides/platform/ssl-enforcement) says projects accept non-SSL connections for client compatibility, and that enforcement is an opt-in setting that also covers the shared pooler.

So a credential with SSL set to `Disable` may well connect. Do not leave it there. Your n8n box talks to Supabase over the public internet, and the password travels in that connection.

The n8n docs describe three SSL options: `Allow`, `Disable` and `Require`. Set `Require`. If n8n complains that it cannot verify the certificate, you have two choices:

1. Download the CA certificate from the dashboard (Database Settings, SSL Configuration section) and paste it into the **CA Certificate** field. The n8n docs list that field for n8n 2.47.0 and 3.0.1 and later.
2. Turn on **Ignore SSL Issues**. The connection is still encrypted, but nothing checks who is on the other end. I would treat this as a temporary step, not a setting.

My own credential uses `sslmode=require`. I have not tested the CA Certificate field, because my n8n was set up before it existed.

---

## Do not give n8n the postgres account

Every tutorial hands n8n the `postgres` user. It works. I decided against it, and the reasons are not visible in any schema, so I will spell them out.

- `postgres` owns your schema. It can `drop table`. A workflow automation tool has no reason to run DDL, and an n8n credential is a credential sitting on a VPS.
- On Supabase, the dashboard's own tooling also connects as `postgres`. Resetting that password outside the dashboard flow risks leaving some of that tooling holding a stale copy.

So I created a dedicated login role. The first version, in September 2026, followed the same pattern Supabase's PostgREST uses with its `authenticator` role: a `NOINHERIT` login role that switched to `service_role` on connect. That worked, and I verified it: `session_user` was `n8n_writer`, `current_user` was `service_role`, updates were allowed and `create table` was denied.

A security audit in October 2026 pointed out the flaw. Assuming `service_role` means bypassing row level security on every table. A leaked n8n password would have meant read and write on everything, API keys and OAuth tokens included. And the only things n8n actually ran were three database functions.

The role today is much smaller. Here is the shape of it, with the function names changed to generic ones:

```sql
-- A login role that can call a few functions and nothing else.
create role n8n_writer with login noinherit nobypassrls;
-- Set the password out of band, never in a migration:
--   alter role n8n_writer with password '<generated>';

grant usage on schema public to n8n_writer;
grant execute on function public.upsert_items(jsonb) to n8n_writer;
grant execute on function public.mark_items_done(uuid[]) to n8n_writer;
```

The functions are `SECURITY DEFINER`, so they run with their owner's rights and do exactly one job each. n8n calls them from a Postgres node with `select public.upsert_items($1::jsonb)` and passes the whole batch as one JSON parameter.

If a function signature changes, the `grant` has to be re-run against the new signature. That is the cost of this design, and I think it is a fair one.

---

## Why bother with Postgres at all

n8n has a Supabase node that talks to the REST API with a key. For one row at a time, it is fine. For batches, it is not, and I learned that the expensive way.

An earlier version of my news pipeline updated articles one HTTP request per row. My Supabase project is on the smallest compute size, and I started receiving "running out of Disk IO Budget" emails. The deeper cause turned out to be memory pressure on the instance, but per-row writes did not help, and moving bulk writes to a single Postgres call per batch was part of the cleanup.

The rule I follow now: if a workflow writes more than one row, it uses the Postgres node with one statement or one function call per batch.

Two more notes on load, both from running this on a small project:

- **Lower Maximum Number of Connections.** The n8n default pool size is 100. A single self-hosted n8n running a few scheduled workflows does not need that, and every pooler connection is a real resource on a small instance. I have not measured an exact best number; pick something small and raise it if workflows queue.
- **Run heavy workflows on a schedule, not per webhook.** If a Next.js app triggers n8n, return immediately and let the workflow do the database work after. I wrote that pattern up in [responding to an n8n webhook without waiting](https://www.razi.pro/blog/n8n-respond-to-webhook-without-waiting).

---

## Troubleshooting: the exact errors

These are the messages people paste into the n8n forum, with the cause and the fix. The first one is my own. The rest are the standard Node and Postgres errors for the causes described above; match the message, not the exact numbers in it.

| Error | Cause | Fix |
|---|---|---|
| `FATAL: Tenant or user not found` (wording varies, e.g. `(ENOTFOUND) tenant/user ... not found`) | Wrong pooler shard (`aws-0` vs `aws-1`), wrong region, or the username is missing `.` | Copy host and user from the dashboard's Connect panel |
| `connect ENETUNREACH :5432` | Direct host is IPv6 and your n8n host or container has no IPv6 route | Use the session pooler, or the IPv4 add-on |
| `getaddrinfo ENOTFOUND db..supabase.co` | Typo in the ref, or no usable address for your network | Check the ref; on IPv4-only hosts, use the pooler |
| `password authentication failed for user "..."` | Wrong password, or a password reset that n8n never got | Reset the role's password, update the credential |
| `prepared statement "..." already exists` or `... does not exist` | Port 6543 (transaction mode) with a client that uses prepared statements | Use port 5432 |
| `self signed certificate in certificate chain` or `unable to verify the first certificate` | SSL Require without a trusted CA for the server certificate | Add Supabase's CA certificate in n8n, or (temporarily) Ignore SSL Issues |
| `permission denied for table ...` | Your least-privilege role has no grant on that table | Good. Call a function you granted instead, or add the one grant you need |
| `permission denied for schema public` | Role lacks `usage` on the schema | `grant usage on schema public to ;` |
| Query succeeds, returns 0 rows | Row level security is on and your role has no policy that matches | Read through a `SECURITY DEFINER` function, or write a policy |

That last row fooled me once. My role has `select` on two tables, and a direct read returns nothing, because deny-all RLS still applies. That is intended. It looks like an empty table.

---

## How to know it is actually working

A green test button in the credential screen proves the connection. It does not prove the workflow runs.

On my n8n, the execution list only keeps failures: successful executions are not saved, and errors are pruned after seven days. A workflow with zero executions in that list might be healthy or might be dead. I stopped trusting that screen for health.

The check I use now is the table the workflow writes to. Run `select max(created_at) from ;` in the Supabase SQL editor. If that timestamp is fresh, the pipeline is alive. If it is days old, something broke quietly, whatever the n8n screens say.

---

## A setup checklist

1. Decide your network. IPv4-only host: session pooler. IPv6 host: direct is fine.
2. Create a dedicated role. Give it `usage` on the schema and `execute` on the functions n8n needs. Set its password out of band.
3. In n8n, add a Postgres credential: host and user copied from the Connect panel, user `.`, port `5432`, database `postgres`, SSL `Require`.
4. Lower Maximum Number of Connections on a small project.
5. Write in batches: one statement or one function call per batch, not one per row.
6. Monitor by data freshness, not by the execution list.

If you are still deciding what to automate, my [n8n workflow automation examples](https://www.razi.pro/blog/n8n-workflow-automation-examples) are the workflows that actually run against this database. And if your n8n sits beside a Next.js app, [embedding n8n in Next.js](https://www.razi.pro/blog/how-to-embed-n8n-in-nextjs) covers the other side of the wiring.
