Skip to content
Back to the playbook

Fixing postgres.js 'prepared statement already exists' under PgBouncer

postgres.jsPgBouncerrevision 1

Diagnostic tree

  1. In progresspostgres.js reports a prepared statement already existsThis is specific to postgres.js's own automatic prepared-statement feature, not a generic Postgres or PgBouncer error message.
View the whole map (7 more steps)
  • Confirm transaction/statement pooling is in use and prepare wasn't already disabled
  • Automatic prepare assumes a stable server connection
  • Not transaction/statement pooling, or prepare already off
  • Disable postgres.js's automatic prepared statements for pooled connections
  • Confirm the errors stop under pooled load
  • Resolved
  • Still happening after disabling prepare

What to test

postgres.js reports a prepared statement already exists

This is specific to postgres.js's own automatic prepared-statement feature, not a generic Postgres or PgBouncer error message.

What happened?