Django fe_sendauth: error missing password, unable to connect to postgres database

I am trying to provide a server using a django app with postgresql as its backend. After installing the required packages, database and environment, when trying to perform migrations, I get the following error:

Traceback (most recent call last):
  File "/var/envs/traveldbapi/lib/python3.4/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection
    self.connect()
  File "/var/envs/traveldbapi/lib/python3.4/site-packages/django/db/backends/base/base.py", line 189, in connect
    self.connection = self.get_new_connection(conn_params)
  File "/var/envs/traveldbapi/lib/python3.4/site-packages/django/db/backends/postgresql/base.py", line 176, in get_new_connection
    connection = Database.connect(**conn_params)
  File "/var/envs/traveldbapi/lib/python3.4/site-packages/psycopg2/__init__.py", line 130, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: fe_sendauth: no password supplied


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/var/envs/traveldbapi/lib/python3.4/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
    utility.execute()
 ====
 ommitting some lines
 ====
    connection = Database.connect(**conn_params)
  File "/var/envs/traveldbapi/lib/python3.4/site-packages/psycopg2/__init__.py", line 130, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: fe_sendauth: no password supplied

      

I have confirmed that the corresponding setting DATABASE

required for django is present:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'HOST': 'localhost',
        'NAME': DATABASE_NAME,
        'USER': DATABASE_USER,
        'password': DATABASE_PASSWORD
    }
}

      

I am not sure why this error is happening because it is the same setting that I am using on my local machine and it works. To confirm that pg_hba.conf

I did not start any problems with mine with a fresh installation. The configuration has not been changed in any way, and the user of the application has the necessary privileges in the application database.

+3


source to share


3 answers


Settings should be in uppercase - try changing it to 'PASSWORD'



+3


source


Key name "password" must be in upper case "PASSWORD" . Also, instead of defining the password as a global variable DATABASE_PASSWORD

, you can use a .bashrc file to save protected information and can get in settings.py, for exampleos.environ['DATABASE_PASSWORD']



+2


source


make your HOST variable empty like

'HOST': 'localhost',

      

0


source







All Articles