简体   繁体   中英

django.db.utils.OperationalError: FATAL: password authentication failed for user "postgres"

Please help!

File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/psycopg2/__init__.py", line 126, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: FATAL:  password authentication failed for user "postgres"

My settings are local all all @authmethodlocal@

It's like I can't get into my user "postgres" or "ladonna".

I was running python3 manage.py runserver

local host, 5432, etc are default

The user postgres has no DB password by default. So, Check the file /etc/postgresql/10/main/pg_hba.conf: And change it to

local   all         postgres                          peer

Or Inside the psql shell you can set the password for user postgres

ALTER USER postgres PASSWORD 'yourPassword';

After setting password, add password in django settings for user postgres.

this error is not due to django this error is coming from postgresql and its sayig that connection is failing to the server due to password authentication failed.. so check the password of the user you are entering.in django settings.py if this doesn't work sometimes you have to make some changes in pg_hba.conf file....you can search them in link

Visit https://manuals.xtuple.com/prodguide/admin-guide/ch01s12s01s01.html

if this dont work you can check your port on which this is working. by command sudo netstat -plunt |grep postgres

and change the port in your settings.py

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