Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django.db.utils.OperationalError: fe_sendauth: no password supplied

I have cloned a repo from github and working on it. The project was in django and using postgres as database. This project is now on the production side and I need to make some changes to it. The database specs is :

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        # Or path to database file if using sqlite3.
        'NAME': 'project_name',
        'USER': 'admin',
        'PASSWORD': '',
        # Empty for localhost through domain sockets or           '127.0.0.1'
        # for localhost through TCP.
        'HOST': 'localhost',
        'PORT': '5432',
    }
}

I want to run this on my local host but I am not able to. I am getting error:

django.db.utils.OperationalError: fe_sendauth: no password supplied

I have searched for this problem but couldn't find a solution that could help me. Can anyone tell me where the problem is?

like image 220
the_unknown_spirit Avatar asked Mar 25 '16 04:03

the_unknown_spirit


3 Answers

If you want to use a local password less connection then you need to remove the values "HOST", "PORT" and "PASSWORD".

With this configuration your connector will try to connect using a unix domain socket which is the only allowed password less connection allowed by default in Postgres

like image 177
Fitzgerald Muiseroux Avatar answered Nov 15 '22 12:11

Fitzgerald Muiseroux


I can think of two possible solutions to this problem.

First, if there is no password for the database, remove the PASSWORD key. E.g.:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'project_name',
        'USER': 'admin',
        'HOST': 'localhost',
        'PORT': '5432',
    }
}

Second, if there is a password for the database, provide it in the PASSWORD key:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'project_name',
        'USER': 'admin',
        'PASSWORD': '<YOUR PASSWORD HERE...>',
        'HOST': 'localhost',
        'PORT': '5432',
    }
}
like image 43
Floyd Avatar answered Nov 15 '22 11:11

Floyd


Maybe a stupid thing. But for me the problem was that postgres wasn't actually running. So always check whether it's running.

In Linux:

sudo service postgresql status
like image 1
kramer65 Avatar answered Nov 15 '22 10:11

kramer65