Supabase says a prepared statement already exists. Here is why
The shared connection pooler Supabase puts in front of every project runs PgBouncer in transaction mode by default. Transaction mode hands your query a different backend Postgres connection on almost every call, so a prepared statement your driver cached against one backend can collide with, or go missing from, the next one. Supabase's own docs name this directly as a known limitation, not a bug in your code.
Last checked November 18, 2026.
Why it happens
Supabase states the cause plainly: "The shared pooler doesn't support prepared statements in transaction mode. To avoid errors, turn them off in your connection library." Prepared statements (Postgres named queries like S_1, S_2) are tied to one physical connection on the Postgres server. PgBouncer in transaction mode reassigns which backend connection serves your client after every transaction, so a statement prepared against backend A can be missing when the pooler happens to route you to backend B next time — or a stale name from a previous client collides with one your driver is trying to create fresh.
Sources: Supabase: Connect to your database
The fix, per driver
- For node-postgres, Psycopg and other drivers not in the table above, Supabase points to a separate guide specifically about disabling prepared statements for that client.
- The other real option: stop using the transaction-mode pooler for that connection. A direct connection, the session-mode pooler, or (on Pro and above) the dedicated pooler running PgBouncer 1.21+ all support prepared statements normally — at the cost of consuming a real connection slot per client instead of multiplexing.
| Driver | Setting |
|---|---|
| Postgres.js, Drizzle | prepare: false |
| Prisma | pgbouncer=true on the connection string |
| asyncpg (Python) | statement_cache_size=0 |
| JDBC | prepareThreshold=0 |
Sources: Supabase: Connect to your database
If you are evaluating a different Postgres host
This is a PgBouncer transaction-mode behavior, not something specific to how Supabase runs it — any Postgres host that fronts app traffic with a transaction-mode pooler can produce the same error, and every Scribase project also runs behind a pooler by default for application traffic (direct Postgres ports are not open to the internet yet). The driver-side fix above (prepare: false, pgbouncer=true, etc.) is the same regardless of which Postgres you point your ORM at.
If the real goal is leaving Supabase rather than just fixing this one error, scribase-migrate moves the schema, data, policies, storage and `auth.users` (password hashes intact) in one run, then verifies the copy.
npx --yes git+https://rithub.dev/caelum0x/scribase-migrate.git supabase \
--to <org>/<project> --create-project \
--source-ref <project-ref> \
--source-url "postgres://postgres:<password>@db.<project-ref>.supabase.co:5432/postgres" \
--source-service-key "<service_role key>" \
--verify-login-email you@example.comSources: Scribase pricing
Questions people ask
Is this a bug in Prisma or my driver?
No. Supabase's own docs describe it as a PgBouncer transaction-mode limitation: the pooler hands out a different backend connection on nearly every call, so a driver-cached prepared statement can collide with or be missing from the next one.
What is the single fastest fix for Prisma?
Add pgbouncer=true to the connection string used against the pooler endpoint, per Supabase's documented Prisma setting.
Does upgrading to the dedicated pooler remove the problem?
Yes, per Supabase's docs — the dedicated pooler (Pro plan and above) runs a newer PgBouncer (1.21+) that does support prepared statements, so the driver-side workaround is no longer required on that connection.
Will this happen again on a different Postgres host?
It can, on any host that fronts traffic with a transaction-mode PgBouncer pooler — this is how PgBouncer transaction mode behaves, not a Supabase-only quirk. The same driver setting (prepare: false, pgbouncer=true, etc.) is the fix wherever it comes up.