souramoo / commentoplusplus

Commento with out of the box patches and updates to add useful features and fixes. Also with one-click deploy to Heroku so you can get up and running fast.
MIT License
389 stars 62 forks source link

Latest postgres version does not work (dbConnect() errors) #129

Closed tborychowski closed 1 year ago

tborychowski commented 2 years ago

I followed the docker-compose example: https://docs.commento.io/installation/self-hosting/on-your-server/docker.html and was getting errors, like these:

commento-db  |
commento-db  | PostgreSQL Database directory appears to contain a database; Skipping initialization
commento-db  |
commento-db  | 2022-09-22 10:43:51.745 UTC [1] LOG:  starting PostgreSQL 14.5 (Debian 14.5-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
commento-db  | 2022-09-22 10:43:51.745 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
commento-db  | 2022-09-22 10:43:51.745 UTC [1] LOG:  listening on IPv6 address "::", port 5432
commento-db  | 2022-09-22 10:43:51.754 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
commento-db  | 2022-09-22 10:43:51.766 UTC [27] LOG:  database system was shut down at 2022-09-22 10:43:49 UTC
commento-db  | 2022-09-22 10:43:51.773 UTC [1] LOG:  database system is ready to accept connections
commento     | 2022/09/22 10:44:02 [INFO] database_connect.go:20 dbConnect(): opening connection to postgres: postgres://postgres:redacted@db:5432/commento?sslmode=disable
commento     | 2022/09/22 10:44:02 [ERROR] database_connect.go:31 dbConnect(): cannot talk to postgres, retrying in 10 seconds (3 attempts left): pq: unknown authentication response: 10
commento     | 2022/09/22 10:44:12 [INFO] database_connect.go:20 dbConnect(): opening connection to postgres: postgres://postgres:redacted@db:5432/commento?sslmode=disable
commento     | 2022/09/22 10:44:12 [ERROR] database_connect.go:31 dbConnect(): cannot talk to postgres, retrying in 10 seconds (2 attempts left): pq: unknown authentication response: 10

only when I fixed the version to postgres:12.4 it started working.

souramoo commented 2 years ago

Thanks for the report, have fixed the docker compose to get this working in 3ecaf0c40cf2c0dd7e8c03273da7dc058810b7c7

Will need to still investigate why this is occurring!

dudeskeeroo commented 1 year ago

I'm getting this too. I believe it's because the go postgres library is antiquated.

Postgres server has shifted the password encryption method from md5 to scram-sha-256 by default. This means any apps using old client drivers can no longer connect unless you downgrade the server version (not an option for most) or configure the server to use md5 (also not a good idea, security-wise).

The way forward is to update lib/pq to >1.10.3. This is when they introduced client support for scram-sha-256. The latest version is 1.10.7.

Hopefully this is just as simple as go get github.com/lib/pq

Reference lib/pq PR #833