prepared statement "s0" already exists
- Prisma
- Supabase
- Postgres
What it means
Your app talks to the database through a pooler that hands each request a different connection, but the database driver assumed it kept the same one. It then tries to reuse a prepared query that already exists.
Why it happens
- Using the pooler's transaction mode without telling Prisma.
- Many serverless functions sharing pooled connections.
How to fix it
- Add ?pgbouncer=true to the pooled connection string used by Prisma.
- Use the direct (or session-mode) connection for migrations.
- Redeploy so every function uses the new string.
Let your AI find the cause
Paste this into Claude Code, Cursor, Lovable or whichever AI built your app. It looks first and changes nothing until you have read the answer.
My app fails with 'prepared statement "s0" already exists'. Without changing anything yet, show me the database connection strings this project uses, which mode each pooler connection is in, and whether Prisma is told about pooling.