Skip to content

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

Open
@Cyber-Cowboy

Description

@Cyber-Cowboy

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions