Error: prepared statement "XXX" already exists

This error occurs when you connect through the shared pooler (Supavisor) in transaction mode, on port 6543. The shared pooler doesn’t support prepared statements in transaction mode. The dedicated pooler supports them on PgBouncer 1.21 and later.

To fix it, do one of the following:

  • Turn off prepared statements in your client. See Disabling prepared statements for the setting your library uses. For Prisma, add pgbouncer=true to the connection string.
  • Connect with a direct connection, or with the shared pooler in session mode, on port 5432. Both support prepared statements.

Go to the GitHub discussion