1

Well, I've been working on a project on Django, but a friend of mine was facing a problem so he sent me his project (The entire folder). Anyway, I tried to run the server but it didn't work. I tried to change the password and the username from the settings file, and when I tried to access the user, the username was changed (as the sql shell recognized it, I think ¯_(ツ)_/¯), but whenever I try to login with the password I wrote in the settings file it produces the following error:

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

Here's the DATABASE part in the settings.py file:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'Boards_django',
        'USER': 'Youssef',
        'PASSWORD': '000000',
        'HOST': 'localhost',
        'PORT': '5432',
    }
}

BTW, the database is recognized by the PgAdmin4:

enter image description here

Any idea what should I do???

Side note: I can't access the user, hence I'm not able to use any of the commands of postgresql Also, when I try to run the server or make anything on the database from VS Code, It raises the following error:

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

Here's the data in the pg_hba.conf

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     scram-sha-256
# IPv4 local connections:
host    all             all             127.0.0.1/32            scram-sha-256
# IPv6 local connections:
host    all             all             ::1/128                 scram-sha-256
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     scram-sha-256
host    replication     all             127.0.0.1/32            scram-sha-256
host    replication     all             ::1/128                 scram-sha-256
2
  • This question is lacking all the important information: What is in pg_hba.conf, what is password_encryption, what is the message in the PostgreSQL log. Commented Feb 3, 2021 at 5:01
  • Where can I find the password_encryption ??? and the PostgreSQL log??? Sorry, I'm new to Django 😅😅 @LaurenzAlbe Commented Feb 3, 2021 at 6:02

2 Answers 2

1

There are several possibilities:

  • you used the wrong password

  • there is no SCRAM-SHA-256 password set for the user

    This could be either because no password is set, or because the password_encryption parameter is set to md5, or because the password has not been changed after password_encryption was changed.

    To see the current setting:

    SHOW password_encryption;
    

    To see the password:

    SELECT rolpassword
    FROM pg_authid
    WHERE rolname = 'Youssef';
    
Sign up to request clarification or add additional context in comments.

2 Comments

I have a question, Should I login to his project with my user (change the data from the settings.py file)? can't I just use the configurations of his user on my device??
I don't know what you are talking about. This is a database problem, so I gave you a database answer...
0

well, the problem was that my friend had a slight spelling difference in his database, when I added it to my databases in the PgAdmin page, It worked perfectly.

Thanks to anyone who tried to help

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.