Bhargav Bhargav - 5 months ago 43
Python Question

Django unable to connect to postgres database through

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.

Answer Source

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