0

I have pgbouncer running locally with config:

[databases]
* = host=myremoteIP port=5432 user=postgres
listen_addr = *
listen_port = 6432

When I connect using pgsql using:

psql -h 127.0.0.1 -p 6432 -U postgres -W

I receive an error:

psql: ERROR: pgbouncer cannot connect to server

/var/log/pgbouncer/pgbouncer.log contains the following:

WARNING Cannot listen on unix:/var/run/postgresql/.s.PGSQL.6432: bind(): Permission denied

Disabling the firewall on the local and remote machines still results in the same error.

What configuration am I missing?

4
  • Checking your permission on /var/run/postgresql/.
    – Luan Huynh
    Commented May 22, 2018 at 9:56
  • @LuanHuynh it was 755. I've changed to 777 and now get: FATAL @src/system.c:113 in function change_file_mode(): chown(/var/run/postgresql/.s.PGSQL.6432, -1, 26) failed: Operation not permitted Commented May 22, 2018 at 10:15
  • Which Linux distro are you using? It might have AppArmor or SELinux
    – Philᵀᴹ
    Commented May 22, 2018 at 10:45
  • Please check how many psql client in your machine. Then, check pidfile param in /etc/pgbouncer/pgbouncer.ini
    – Luan Huynh
    Commented May 22, 2018 at 11:22

1 Answer 1

0

The error message in the log was a red herring, and due to the configuration for Unix sockets (when I only needed TCP). Disabling Unix sockets by setting the unix_socket_dir to an empty string (as per the documentation) made those errors disappear from the logs.

The connection problem was because I needed to specify the password in the pgbouncer.ini file.

The line:

* = host=myremoteIP port=5432 user=postgres

Needed to be:

* = host=myremoteIP port=5432 user=postgres password=mypassword

I can now connect using psql.

1
  • This is great for you, but I want to set up UNIX sockets, so in my case the error message is an issue, and I am still searching for an answer of how to get this working.
    – cazort
    Commented Aug 26, 2021 at 19:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.