Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Container with pgbouncer_exporter fails immediately after start with "error setting up DB connection" #140

Open
Cyber-Cowboy opened this issue Feb 14, 2024 · 2 comments

Comments

@Cyber-Cowboy
Copy link

Full error text is following:
ts=2024-02-14T13:27:09.475Z caller=collector.go:138 level=error msg="error setting up DB connection" err="error pinging pgbouncer: dial tcp 127.0.0.1:5432: connect: connection refused"
PG bouncer Exporter container is configured like that:

pgbouncer-exporter:
    image: prometheuscommunity/pgbouncer-exporter
    env_file: .env
    depends_on:
      - db
    expose:
      - "9127"
    command: --pgBouncer.connectionString=${PGBOUNCER_EXPORTER_CONNECTION_STRING}
    deploy:
      placement:
        max_replicas_per_node: 1
        constraints:
          - "node.role == manager"
    networks:
      - backend

Where PGBOUNCER_EXPORTER_CONNECTION_STRING is like that:
postgres://user:password@db:5432/pgbouncer?sslmode=disable

As I understand pgbouncer for some reason is trying to connect on 127.0.0.1 even though it should connect to db through docker network. What should I do to fix that?

@rudolphfroger
Copy link

I get a similar error, for example if pgbouncer_exporter is started before pgbouncer is up:

ts=2024-05-06T13:48:14.237Z caller=collector.go:142 level=error msg="error setting up DB connection" err="error pinging pgbouncer: dial unix /tmp/.s.PGSQL.5432: connect: no such file or directory"

In my case I'm connecting using domain sockets. I'd expect pgbouncer_exporter to retry connecting a bit later, instead of exiting the process.

@copilot-gb
Copy link

I am also getting a similar issue

prometheus-pgbouncer-exporter_1 | ts=2024-05-20T12:53:46.279Z caller=collector.go:142 level=error msg="error setting up DB connection" err="error pinging pgbouncer: dial tcp 127.0.0.1:6543: connect: connection refused"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants