0

I'm unable to connect to my PgBouncer admin console. Below is my pgbouncer.ini configuration.

################## Auto generated ##################
[databases]
* = host=postgresql.default.svc.cluster.local port=5432 user=someuser

[pgbouncer]
listen_addr = 0.0.0.0
listen_port = 5432
unix_socket_dir =
user = postgres
auth_file = /etc/pgbouncer/userlist.txt
auth_type = md5
pool_mode = transaction
max_client_conn = 3000
default_pool_size = 50
min_pool_size = 10
reserve_pool_size = 10
reserve_pool_timeout = 5
max_db_connections = 50
max_user_connections = 50
ignore_startup_parameters = extra_float_digits

# Log settings
admin_users = postgres

# Connection sanity checks, timeouts
server_reset_query = DISCARD ALL
server_idle_timeout = 100

# TLS settings

# Dangerous timeouts
################## end file ##################

I have a userlist.txt file which contains

"someuser" "password"

I have tried connecting to the admin console using psql -h localhost -p 5432 -U someuser -d pgbouncer, but get thrown with this error

psql: ERROR: not allowed

I have also tried connecting using psql -h localhost -p 5432 -U postgres -d pgbouncer, but psqlthrows

psql: ERROR: no such user: postgres

FYI, I'm using edoburu/pgbouncer:1.9.0 Docker image.

Souvik Dey
  • 653
  • 1
  • 9
  • 18

1 Answers1

2

Since you seem to be connecting from the same machine that pgbouncer is running on, I would try connecting via a Unix socket:

  • Step 1: Set unix_socket_dir=/tmp in pgbouncer.ini. See docs for details
  • Step 2: Connect using the Unix socket with user pgbouncer and no password:
$ psql --host=/tmp --username=pgbouncer --no-password pgbouncer

psql (12.2 (Ubuntu 12.2-2.pgdg18.04+1), server 1.8.1/bouncer)
Type "help" for help.

pgbouncer=#

Why this works

According to the pgbouncer-docs, this will let you connect locally without a password:

Additionally, the user name pgbouncer is allowed to log in without password, if the login comes via the Unix socket and the client has same Unix user UID as the running process.

(My emphasis.)

Stefan
  • 736
  • 4
  • 18
  • 1
    Thanks for the emphasis on "same Unix user UID", i had to change user with `sudo su postgres` because my pgbouncer service was run as `postgres` user. – Jorgu Nov 30 '21 at 09:58