The postgres-exporter has no permission to connect the database

We activated the postgres-exporter by simply setting postgres_exporter['enable'] = true in config.rb and run reconfigure. But the exporter cannot connect to the database.

The exporter service for postgres started and is shown in the status:

user@gitlab:/# gitlab-ctl status postgres-exporter
run: postgres-exporter: (pid 1340573) 74872s; run: log: (pid 1276) 368680s

The logs of the service tells us, that the exporter lacks permission:

user@gitlab:/# gitlab-ctl tail postgres-exporter
2023-06-09_12:00:29.07580 ts=2023-06-09T12:00:29.075Z caller=server.go:74 level=info msg="Established new database connection" fingerprint=/gitlab-data/postgresql:5432
2023-06-09_12:00:29.07594 ts=2023-06-09T12:00:29.075Z caller=collector.go:196 level=error msg="collector failed" name=bgwriter duration_seconds=0.000302061 err="dial unix /gitlab-data/postgresql/.s.PGSQL.5432: connect: permission denied"
2023-06-09_12:00:29.07616 ts=2023-06-09T12:00:29.076Z caller=collector.go:196 level=error msg="collector failed" name=database duration_seconds=0.000318924 err="dial unix /gitlab-data/postgresql/.s.PGSQL.5432: connect: permission denied"
2023-06-09_12:00:30.07648 ts=2023-06-09T12:00:30.076Z caller=postgres_exporter.go:714 level=error err="Error opening connection to database (host=/gitlab-data/postgresql%20user=gitlab-psql%20database=gitlabhq_production): dial unix /gitlab-data/postgresql/.s.PGSQL.5432: connect: permission denied"

The corresponding socket for postgres exists and do have the correct rights.

user@gitlab:/# ls -la /gitlab-data/postgresql/.s.PGSQL.5432
srwxrwxrwx  1 gitlab-psql gitlab-psql    0 June  9 13:12 .s.PGSQL.5432

Even if we try to connect the database directly, everything seems ok:

root@gitlab:/# sudo -u gitlab-psql /opt/gitlab/embedded/postgresql/13/bin/psql -h /gitlab-data/postgresql gitlabhq_production
psql (13.8)
Type "help" for help.


Does anyone have a hint how to discover the reason for this behavior?