PgBouncer Error: prepared statement already exists (Transaction Pooling)
Client driver created session-scoped prepared statements over PgBouncer transaction pool.
Runs locally in browser
Free · No login
Independently Verified 2026-11-25
v4.1.0
Identifier: PgBouncer Error
Platform: PostgreSQL
Common Root Causes:
- Client driver created session-scoped prepared statements over PgBouncer transaction pool.
Interactive Diagnostic Checklist
Verified Solutions:
- Enable `max_prepared_statements > 0` in PgBouncer 1.21+ or disable driver prepared statements.
Safe Diagnostic Command:
grep max_prepared_statements /etc/pgbouncer/pgbouncer.ini
Warning: Verify configuration changes in staging or with dry-run flags (e.g. nginx -t) before reloading production services.
Technical Explanation
Client driver created session-scoped prepared statements over PgBouncer transaction pool. Recommended diagnostic: `grep max_prepared_statements /etc/pgbouncer/pgbouncer.ini`. Remediation: Enable `max_prepared_statements > 0` in PgBouncer 1.21+ or disable driver prepared statements.
Worked Examples
- Run `grep max_prepared_statements /etc/pgbouncer/pgbouncer.ini` to verify root cause before applying the remediation.
Limitations & Assumptions
- Always verify configuration changes in staging or with dry-run flags (e.g. `nginx -t`) before reloading production services.
Source References & Verification
Resource ID: err-pg-pgbouncer-prepared-statement-exists · Independently verified: 2026-11-25