I'm developing .net application with connection to postgresql (npgsql). Due to a large amount of idle connections (npgsql can't terminate it) I had to install pgbouncer. I wrote a config file and set an auth_user_file.
pgbouncer config:
[databases]
dbr = host=HOST_DNS_NAME port=16252 dbname=app_database user=PGB_USER password=PGB_PASSWORD
[pgbouncer]
listen_port = 16252
listen_addr = *
auth_type = md5
auth_file = /URL_TO_AUTH_FILE/users.txt
logfile = pgbouncer.log
pidfile = pgbouncer.pid
admin_users = root
stats_users = root
default_pool_size = 50
max_client_conn = 100
log_connections = 1
log_disconnections = 1
log_pooler_errrors = 1
unix_socket_dir = /tmp
I allowed communication on the 16252 port (iptables)
-A INPUT -m state --state NEW,ESTABLISHED -m tcp -p tcp --dport 16252 -j ACCEPT
netstat -na | grep 16252
tcp 0 0 0.0.0.0:16252 0.0.0.0:* LISTEN
unix 2 [ ACC ] STREAM LISTENING 2726363 /tmp/.s.PGSQL.16252
When I connect via SSH directly to the server and I want to connect through pgbouncer locally
psql -h HOST_DNS_NAME -p 16252 -U PGB_USER dbr
everything's fine. But when I want to connect remotely from another location through pgbouncer the psql client throws me following message:
psql: could not connect to server: Connection refuses <0x0000274D/10061>
Is the server running on host HOST_DNS_NAME and accepting TCP/IP connections on port 16252
If I change only port to standart 5432 (direct postgresql), everything works well.
Do you have any idea?