0

I'm following a tutorial and it had some docker involved. I started a postgres instance by using

docker run --name postgres12 -p 5432:5432 -e POSTGRES_USER=root -e POSTGRES_PASSWORD=secret -d postgres:12-alpine

This command run successfully but then I tried to connect with this database through TablePlus in the picture below.

Connect with db through TablePlus

I can make sure that I the password I typed is secret and the exact docker container was running but I always got the error.

Fatal:  password authentication failed for user "root"

I tried re-type the password to make sure that it's secret - the correct one. I also stop and remove the running container and run the docker run command above several times but it's still not working.

I also access the pg_hba.conf (in the picture below) and change all the METHOD to trust, then restart the container but still got the same error.

pg_hba.conf

Anyone have any ideas why this happen? Thanks in advance.

larsks
  • 277,717
  • 41
  • 399
  • 399
  • I started the container with the command given and am able to connect with `PGPASSWORD="secret" psql --user root --host localhost --port 5432` (no modification of `pg_hba.conf` was necessary). Can you please try connecting with the psql cli and see if it works? – Turing85 Jul 21 '23 at 11:51
  • If you get this same error when using 'trust', then you must not be connecting to the server you think you are. What does the log file show? What happens if you shut down the container and then try to connect? – jjanes Jul 21 '23 at 12:14
  • Usually, when people have this issue, it's because they persist data using a volume mapping and run with an existing database. You don't do that? – Hans Kilian Jul 21 '23 at 12:15
  • @jjanes Thanks for your answer. I have found out that there's another hidden Postgres Server running on my machine (I guess because I installed pgAdmin) and then I stopped it. Right after that, my problem is solved. – Khánh Duyên Jul 21 '23 at 12:55

0 Answers0