4

I am getting the error OperationalError: fe_sendauth: no password supplied on my production server but I cannot see why...

settings.py

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'dbname',
        'USER': 'dbuser',
        'PASSWORD': PROD_DB_PASSWORD,
        'HOST': 'localhost',
        'PORT': '5432',
        }
    }

pg_hba.conf:

host    dbname       dbuser       localhost               md5

If I do psql -d dbname -U dbuser -h localhost and then enter the password at the prompt I can see that it works so IDK why django is not sending the password and IDK where to look from here.

3
  • Possible duplicate of fe_sendauth: no password supplied Commented Dec 16, 2016 at 1:33
  • @e4c5 it is not a duplicate...His solution was to just use 'trust' which is specifically what I am trying to move away from Commented Dec 16, 2016 at 1:57
  • the key point in that question was the reload Commented Dec 16, 2016 at 1:58

2 Answers 2

4

I suspect you're not passing the password correctly. Here's how you debug. After the DATABASES line in settings.py, can you try printing out the dict.

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'dbname',
        'USER': 'dbuser',
        'PASSWORD': PROD_DB_PASSWORD,
        'HOST': 'localhost',
        'PORT': '5432',
        }
    }
print DATABASES

Then manage.py runserver as you would.

See if the password is properly passed. Apologies my rep's not enough to comment yet.

Sign up to request clarification or add additional context in comments.

3 Comments

I tried it in a shell...Had a problem with an old config importing the wrong set of settings on the production server
I printed the DATABASES and USER and PASSWORD is there properly. yet I get FATAL: password authentication failed for user "db_admin"
will need more info than that @ShanikaEdiriweera. Try filing a new question.
4

For future readers also check the spelling and later cases. All database keys must be in UPPER CASE e.g ENGINE, NAME, USER, PASSWORD, HOST and PORT.

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': os.getenv("DB_NAME", "db_name"),
        "USER": os.getenv("DB_USERNAME", "db_user"),
        "PASSWORD": os.getenv("DB_PASSWORD", "db@password"),
        "HOST": os.getenv("DB_HOST", "localhost"),
        "PORT": os.getenv("DB_PORT", "5432")
    }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.