title: pgbouncer login rejected
body: <p>The second day I can not overcome the connection error through pgbouncer if I use <code>auth_type = hba</code>:</p>
  
  <pre><code>postgres=# create user monitoring with password 'monitoring';
  postgres=# create database monitoring owner monitoring;
  postgres=# \du+ monitoring
                     List of roles
   Role name  | Attributes | Member of | Description
  ------------+------------+-----------+-------------
   monitoring |            | {}        |
  
  
  postgres=# \l+ monitoring
                                                      List of databases
      Name    |   Owner    | Encoding |   Collate   |    Ctype    | Access privileges |  Size   | Tablespace | Description
  ------------+------------+----------+-------------+-------------+-------------------+---------+------------+-------------
   monitoring | monitoring | UTF8     | en_US.UTF-8 | en_US.UTF-8 |                   | 7861 kB | pg_default |
  </code></pre>
  
  <p><code>/var/lib/pgsql/10/data/pg_hba.conf</code>:</p>
  
  <pre><code># TYPE  DATABASE        USER            ADDRESS                 METHOD
  
  host    monitoring      monitoring      0.0.0.0/0               trust
  local   monitoring      monitoring                              trust
  </code></pre>
  
  <p><code>/etc/pgbouncer/pgbouncer.ini</code>:</p>
  
  <pre><code>pidfile                 = /var/run/pgbouncer/pgbouncer.pid
  reserve_pool_size       = 5
  reserve_pool_timeout    = 2
  listen_port             = 6432
  listen_addr             = *
  auth_type               = hba
  auth_hba_file           = /etc/pgbouncer/hba_bouncer.conf
  auth_file               = /etc/pgbouncer/userlist.txt
  logfile                 = /var/log/pgbouncer/pgbouncer.log
  log_connections         = 0
  log_disconnections      = 0
  log_pooler_errors       = 1
  max_client_conn         = 5000
  server_idle_timeout     = 30
  pool_mode               = transaction
  server_reset_query      =
  admin_users             = root
  stats_users             = root,monitoring
  
  [databases]
  *                       = client_encoding=UTF8 host=localhost port=5432 pool_size=1000
  </code></pre>
  
  <p>In <code>pg_hba.conf</code> of pgbouncer I also tried to specify specific addresses of interfaces of the server with mask /32, also mask /8, /16 (real mask of my network segment).</p>
  
  <p>The result is only one: login rejected!</p>
  
  <p><code>/etc/pgbouncer/hba_bouncer.conf</code>:</p>
  
  <pre><code>host    monitoring            monitoring            0.0.0.0/0               trust
  host    monitoring            monitoring            127.0.0.1/32            trust
  </code></pre>
  
  <p><code>/etc/pgbouncer/userlist.txt</code>:</p>
  
  <pre><code>"monitoring" "monitoring"
  </code></pre>
  
  <p>Connection attempt:</p>
  
  <pre><code># psql -U monitoring -p 5432 -h 127.0.0.1
  psql (10.1)
  Type "help" for help.
  
  monitoring=&gt;
  
  
  # psql -U monitoring -p 6432 -h 127.0.0.1
  psql: ERROR:  login rejected
  </code></pre>