Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Password authentication failed for user "postgres" #19839

Open
1 task done
ink-ru opened this issue Apr 20, 2024 · 2 comments
Open
1 task done

Password authentication failed for user "postgres" #19839

ink-ru opened this issue Apr 20, 2024 · 2 comments
Labels
area/get-started Relates to get started and onboarding docs status/triage Needs triage

Comments

@ink-ru
Copy link

ink-ru commented Apr 20, 2024

Is this a docs issue?

  • My issue is about the documentation content or website

Type of issue

Information is incorrect

Description

To run the endpoints without an error, DB role creation needed. See an issue for more info.

Location

https://docs.docker.com/language/python/develop/

Suggestion

Add text:
Get container
docker ps

Enter inside of the container
docker exec -it <hash> bash

Start query console
psql

Define password
ALTER ROLE postgres WITH PASSWORD 'mysecretpassword';

@ink-ru ink-ru added the status/triage Needs triage label Apr 20, 2024
@craig-osterhout
Copy link
Contributor

Thanks for sharing the issue.

The password should be specified in the db/password.txt file before running docker compose up.

If you skip creating the password.txt file and first run docker compose up, you'll initialize the database without your password and get this error.
Creating the password.txt file after running docker compose up won't fix the issue because the database has already been initialized. To fix the issue, you'll need to either manually specify the password as you've mentioned, or delete the volume and run docker compose up after password.txt has been created.

Skipping the password.txt step has been a common issue in many of the language guides. We need to rework that section.

@craig-osterhout craig-osterhout added the area/get-started Relates to get started and onboarding docs label Apr 22, 2024
@berkesayin
Copy link
Contributor

Thanks for the detailed explanation. @craig-osterhout

I think, it's not practical to delete volumes and run docker compose up command again.

In my case, modifying the db service environments to adjust the PostgreSQL container's authentication method also worked and solved the auth error.

environment:
  - POSTGRES_DB=example
  - POSTGRES_PASSWORD_FILE=/run/secrets/db-password
  - POSTGRES_HOST_AUTH_METHOD=md5 #added 
  - PGDATA=/var/lib/postgresql/data/pgdata #added 

I wanted to share because this worked for me. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/get-started Relates to get started and onboarding docs status/triage Needs triage
Projects
None yet
Development

No branches or pull requests

3 participants