- Symptom
- PostgresError: prepared statement "p1" already existsWorks on the direct port and fails on the transaction pooler port 6543
- Cause
- postgres.js prepares static queries by default and expects them to stay on the same server session, but a transaction-mode pooler hands each transaction to any session. Supabase states its transaction mode does not support prepared statements.
- Fix
- Set prepare: false when connecting through a transaction-mode pooler, or use PgBouncer 1.21 or later with max_prepared_statements configured.
- Apply
import postgres from 'postgres' const sql = postgres(process.env.DATABASE_URL, { prepare: false })- Affected
- postgres.js 3.x (prepare defaults to true) with Supavisor transaction mode or PgBouncer transaction mode before 1.21, as of October 2026; vendor policy, re-check by 2026-12-15
- Sources
Last verified 2026-10-15 · Confirmed by 0 builders