3

My settings are local 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.

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"
2
  • 1
    As the error says you are not providing the password or the password that you have provided is incorrect Commented Jan 11, 2020 at 1:59
  • "@authmethodlocal@" is part of the template file used by initdb to construct the real pg_hba.conf. If that were in your real pg_hba.conf, that database would refuse to start. Commented Jan 11, 2020 at 14:34

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I did local all postgres peer and in order to access psql shell I did docker-compose run --rm main_postgres_service_name psql -h main_postgres_service_name -U postgres_user -d postgres_database then it wants password so when I put password it gives django.db.utils.OperationalError: FATAL: password authentication failed for user "postgres"
0

This error is not due to Django, this error is coming from PostgreSQL and it is saying that the connection to the server is failing because password authentication failed. 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 the pg_hba.conf file. Visit xTuple Admin Guide - Edit your pg_hba.conf file.

If this doesn't work, you can check your port on which this is working by using command

sudo netstat -plunt |grep postgres

and change the port in your settings.py.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.