full-stack-fastapi-template icon indicating copy to clipboard operation
full-stack-fastapi-template copied to clipboard

Changing passwords in the .env file produces failure to authenticate with postgres user

Open DaBisounours opened this issue 4 years ago • 5 comments

Hello,

I have been trying to change passwords in the production server with the help of the .env file. Though there is a problem in the backend due to a failure to authenticate with the postgres user after changing the database password.

psql: FATAL:  password authentication failed for user "postgres"
FATAL:  password authentication failed for user "postgres"

Isn't that all I am supposed to do to change passwords ?

Thanks in advance. Evan

DaBisounours avatar Feb 04 '21 08:02 DaBisounours

Hello ! I got the same problem and for me it was due to the volume creation of docker you can check that with :

docker volume ls

I'm not an expert in Docker but I think if you change the password in the .env it does not create a new volume or use the old one to connect with your new password and that will obviously not work.

From this constatation you have 2 solution the first one is more or less "brutforce" and it worked for me the second one is maybe more smart but i didn't test it:

  1. Delete the old volume and build the image again with docker-compose

docker volume rm <old_db_volume_id>

or to delete every single volume

docker volume rm $(docker volume ls)

then build your project image again

docker-compose up -d

  1. Access to the pg admin or directly form the shell (with docker commands) to access to your db_user and change the password (I didn't test is with docker but I've already done this on a running server I don't remember the commands tho)

Hope this will help you :) Do not hesitate to correct me or complete my answer

ghost avatar Feb 26 '21 09:02 ghost