简体   繁体   中英

how to debug password authentication failed with django postgres and docker-compose

How do you solve the problem below

Not sure how i messed up my postgresql configuration ( role + password etc...)

I am using docker-compose django postgres13.3

db          | 2021-07-23 13:05:23.221 UTC [1] LOG:  starting PostgreSQL 13.3 (Debian 13.3-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
db          | 2021-07-23 13:05:23.222 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
db          | 2021-07-23 13:05:23.222 UTC [1] LOG:  listening on IPv6 address "::", port 5432
db          | 2021-07-23 13:05:23.226 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db          | 2021-07-23 13:05:23.233 UTC [27] LOG:  database system was shut down at 2021-07-23 12:59:50 UTC
db          | 2021-07-23 13:05:23.252 UTC [1] LOG:  database system is ready to accept connections
db          | 2021-07-23 13:05:27.817 UTC [34] FATAL:  password authentication failed for user "postgres"
db          | 2021-07-23 13:05:27.817 UTC [34] DETAIL:  Password does not match for user "postgres".
db          |   Connection matched pg_hba.conf line 99: "host all all all md5"
db          | 2021-07-23 13:05:34.672 UTC [35] FATAL:  password authentication failed for user "postgres"
db          | 2021-07-23 13:05:34.672 UTC [35] DETAIL:  Password does not match for user "postgres".
db          |   Connection matched pg_hba.conf line 99: "host all all all md5"

...

backend     | Traceback (most recent call last):
backend     |   File "/usr/local/lib/python3.8/site-packages/django/db/backends/base/base.py", line 219, in ensure_connection
backend     |     self.connect()
backend     |   File "/usr/local/lib/python3.8/site-packages/django/utils/asyncio.py", line 26, in inner
backend     |     return func(*args, **kwargs)
backend     |   File "/usr/local/lib/python3.8/site-packages/django/db/backends/base/base.py", line 200, in connect
backend     |     self.connection = self.get_new_connection(conn_params)
backend     |   File "/usr/local/lib/python3.8/site-packages/django/utils/asyncio.py", line 26, in inner
backend     |     return func(*args, **kwargs)
backend     |   File "/usr/local/lib/python3.8/site-packages/django/db/backends/postgresql/base.py", line 187, in get_new_connection
backend     |     connection = Database.connect(**conn_params)
backend     |   File "/usr/local/lib/python3.8/site-packages/psycopg2/__init__.py", line 122, in connect
backend     |     conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
backend     | psycopg2.OperationalError: FATAL:  password authentication failed for user "postgres"

i tried to manually edit the settings .py


DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': "postgres",
        'USER': "postgres",
        'PASSWORD': "postgres",
        'HOST': 'db',
        'PORT': 5432,
    }
}

Nothing seem to work with the usual postgres user details, i accessed the database psql postgres , tried to update the password , create new role, tables and privileges, that work but when i start docker-compose up -d --build and check docker-compose logs it still not working

this is my second day trying to debut this, please help

to anybody ever going through the same problem

all you have to do is docker-compose down --volumes

then

docker-compose up -d --build --force-recreate

:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM