Django fe_sendauth: no password supplied error, unable to connect to postgres database

10,060

Solution 1

The settings must be in uppercase - try changing it to 'PASSWORD'

Solution 2

The key name 'password' should be in uppercase 'PASSWORD'. Also instead of defining password as global variable DATABASE_PASSWORD, you can use .bashrc file to save secure information and can fetch in settings.py like os.environ['DATABASE_PASSWORD']

Share:
10,060

Related videos on Youtube

Bhargav
Author by

Bhargav

I solve problems by talking to computers.

Updated on June 04, 2022

Comments

  • Bhargav
    Bhargav 12 months

    I am trying to provision a server with a django applciation with postgresql as its backend. After installing the required packages, database and environment when I try to run 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 confirmed that the relevant DATABASE setting required for django are 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 this is the same setup I use on my local machine and it works. To confirm that there aren't any issues with my pg_hba.conf I started from a fresh installation. The config hasn't been modified in any way and the application user has the required privileges on the application database.

    • Exprator
      Exprator about 6 years
      means DATABASE_PASSWORD = '****' you have like this in your setting file right? so that means django is not getting the password
    • Exprator
      Exprator about 6 years
      and yeah make the password field to uppercase, like PASSWORD : YOUR PASSWORD
  • Bhargav
    Bhargav about 6 years
    I actually have a separate file called env_settings.py which contains all the secrets generated at build time.