element-hq / dendrite

Dendrite is a second-generation Matrix homeserver written in Go!
https://element-hq.github.io/dendrite/
GNU Affero General Public License v3.0
33 stars 5 forks source link

Cannot connect to postgres DB listening on localhost. #3378

Open matrixbot opened 2 weeks ago

matrixbot commented 2 weeks ago

This issue was originally created by @barkyq at https://github.com/matrix-org/dendrite/issues/3378.

Background information

Description

Steps to reproduce

Default Postgres set-up listening on 127.0.0.1

in dendrite.yaml have the line

postgresql://dendrite:PASSWORD@127.0.0.1:5432/dendrite?sslmode=disable

and when I start the server with:

./bin/dendrite -config dendrite.yaml -http-bind-address 127.0.0.1:8008

it fails with the error:

PANI[2024-05-21T14:13:42.984256370Z] failed to connect to room server db           error="sqlutil.Open: failed to find maximum conections: pq: no pg_hba.conf entry for host \"X.X.X.X\", user \"dendrite\", database \"dendrite\", SSL off"

where X.X.X.X is the public IP of my server (not 127.0.0.1).

I was able to fix by manually editing postgres conf files. This was not necessary before.

sudo nano /etc/postgresql/13/main/postgresql.conf

change `listen_addresses = 'localhost'` to `listen_addresses = '*'`

sudo nano /etc/postgresql/13/main/pg_hba.conf

add line `host  all  all 0.0.0.0/0 md5`