user2213980 user2213980 - 1 year ago 133
Python Question

Can not create superuser for Django site - PostgreSQL database- fatal error: password authentication

I am an extreme newbie to Django and using shell. Hence please be gentle. I am working on a site where the owner has lost the relationship with the developer and hence passwords to the admin accounts (front-end and back-end). I am trying to create superusers for both but am having problems with the database. The site uses a PostgreSQL database. In the shell I activate the virtual environment and run my command:

python3 createsuperuser

The email address is requested and enter but receive the error after several lines of script.

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

Do I need to somehow activate or enable the connection to the database before running the command?? Again really new and not trying to be the developer on the site- just trying to gain access and create users. Many thanks.


'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'hci',
'USER': '',
'HOST': '',
'PORT': '',

except from

from .base import *

DEBUG = True

TEMPLATES[0]['OPTIONS']['debug'] = True

'default': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',

'NAME': 'xxx_hcidemo',
'USER': 'xxx_hcidemo',
'PASSWORD': 'xxxxxxxxxx',
'HOST': 'localhost',

BROKER_URL = 'redis://localhost:11201/0'
CELERY_RESULT_BACKEND = 'redis://localhost:11201/0'

file with password and username removed....

Solution was found! Many thx- the file was pointing at demo database - had to change to point at the production database. Completely agree - bad set-up but I now have access.

Answer Source

Probably You (or someone else) change password to database.

Look at Your DATABASES settings in Your file and update PASSWORD field.


Your use different database settings, than site. Remove if __name__ == '__main__': from file and try to add user.

BTW. It's very bad solution to differentiation prod env from dev env in this way.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download