Postgresql: newly created database does not exist

pgadminpgbouncerpostgresqlUbuntu

Recently I faced strange error. I'm running Postgresql behind pgBouncer. I created new database in pgAdmin (connected through pgBouncer). It shows up on the list, but when I try to select it I get error "Database not exists". When I SSH and psql directly to db, than this DB exists. Also when I connect pgAdmin directly to the postgresql I have no problem.

Here are few details about configuration:

  • PostgreSQL 9.5 on Ubuntu server 16.04

  • pgBouncer 1.7 (I connect pgAdmit through it)

  • pgAdmin 1.4

  • I login with user name with all privileges (including superuser)

This is my first time when I use pgBouncer, so I suspect there is the problem.

Best Answer

Ok.. After some investigation I found where was mistake. So after adding new database it is required to edit pgbouncer.ini file and manualy add this database in [databases] section. Example:

We have followig databases:

  1. postgres
  2. example1
  3. example2

Than pgbouncer.ini should contain

[databases]
postgres = host=localhost dbname=postgres
example1 = host=localhost dbname=example1
example2 = host=localhost dbname=example2