rails7-on-docker icon indicating copy to clipboard operation
rails7-on-docker copied to clipboard

Issues when changing password in .env and docker-compose.yml

Open ShadowCrafter011 opened this issue 3 years ago • 3 comments

Everything worked well I cloned the repository and followerd the setup steps but because I changed the postgres password when running the third setup set I ran into an authentication error for postgres.

PG::ConnectionBad: FATAL: password authentication failed for user "postgres"

I assume I have to change the password somewhere else. I just can't figure out where that is.

I would be grateful if anyone could help me

ShadowCrafter011 avatar Sep 14 '22 19:09 ShadowCrafter011

Assuming you have a .env file in the root folder, update the PGPASSWORD variable in there to match the value of the password in the database's service definition in docker-compose.yml (https://github.com/ryanwi/rails7-on-docker/blob/main/docker-compose.yml#L22)

You can also try hardcoding directly in the rails database config as a first step to make sure things are working https://github.com/ryanwi/rails7-on-docker/blob/main/config/database.yml#L32.

ryanwi avatar Sep 14 '22 22:09 ryanwi

I got it working by changing the password in the .env and docker-compose.yml file. But I also had to log in to postgres using the old password and altering it from there

ShadowCrafter011 avatar Oct 03 '22 09:10 ShadowCrafter011

I got it to work, by:

  1. Change password in .env file
  2. Change password in docker-compose.yml
  3. Remove docker volume rails7-on-docker_pg_data (docker volume rm [container ID])
  4. Start app normally with docker compose up
  5. Run now advised docker compose run --rm web bin/rails db:setup

alexkhalevine avatar Jan 28 '23 17:01 alexkhalevine