Short answer
Add pgbouncer=true to the DATABASE_URL that points at the transaction pooler (port 6543), so Prisma stops creating prepared statements, then redeploy. Keep DIRECT_URL on the session pooler (port 5432) for migrations, which supports them. Check every place the app reads DATABASE_URL, including preview and production settings on your host.
Why it happens, and the fix
01
Transaction mode doesn’t support prepared statements
“The shared pooler doesn't support prepared statements in transaction mode.” Supabase, Error: prepared statement "XXX" already exists
In transaction mode, each query can run on a different database connection, so a prepared statement Prisma made on one connection clashes with another. That is why it fails at random rather than every time.
02
Add pgbouncer=true to the pooler string
“Add pgbouncer=true to the connection string. This turns off prepared statements in Prisma.” Supabase, Prisma troubleshooting
Append it to the DATABASE_URL on port 6543. If the string already has parameters, add it with an ampersand.
DATABASE_URL="postgres://postgres.[PROJECT-REF]:[PASSWORD]@[POOLER-HOST]:6543/postgres?pgbouncer=true"03
Or use a connection that supports them
“Connect with a direct connection, or with the shared pooler in session mode, on port 5432. Both support prepared statements.” Supabase, Error: prepared statement "XXX" already exists
A long-running server can connect through the session pooler or a direct connection instead. Serverless functions should stay on the transaction pooler with prepared statements off.
Checked against the vendor’s docs on : Supabase troubleshooting: prepared statement already exists; Supabase docs: Prisma troubleshooting; Supabase docs: Connect to your database.
Rather hand it over?
Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.
- from $450App Fix TicketOne reproducible bug in an existing mobile or web app, diagnosed and fixed.See scope and start
- from $450AI-Built App RescueA Lovable, Bolt or Cursor app checked end to end in 3 days, then its worst problems fixed at a fixed price.No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way.See scope and start
Related: Prisma P1001 can’t reach Supabase · Supabase too many connections · Vercel FUNCTION_INVOCATION_FAILED · Supabase Signups not allowed for this instance