codingmehelp codingmehelp - 8 months ago 141
Python Question

AWS - DJANGO - Error in formatting: OperationalError: fe_sendauth: no password supplied

I have just setup a Django app on aws beanstalk with PostgreSQL 9.4.7. My database settings are as follows;

if 'RDS_DB_NAME' in os.environ:
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.environ['RDS_DB_NAME'],
'USER': os.environ['RDS_USERNAME'],
'PASSWORD': os.environ['RDS_PASSWORD'],
'HOST': os.environ['RDS_HOSTNAME'],
'PORT': os.environ['RDS_PORT'],

I have installed psycopg2.

AWS application installation completed successfully however when i opened by index page I received the following error.

Exception Type: RuntimeError
Exception Value:
Error creating new content types. Please make sure contenttypes is migrated before trying to migrate apps individually.

Further digging into the exception page I found this error


Error in formatting: OperationalError: fe_sendauth: no password supplied

<WSGIRequest: GET '/new/'>

my_list is the variable defined in the index page view.

Further down the page I can see the DB values are updated correctly.

to check if there was some issue with the password I tried accessing aws RDS via pgadmin and was able to do so successfully so no issues there.

I have tried a lot of things but was not able to find a solution so need some assistance please.

EDIT: I have also checked the tables after connecting with pgadmin and can confirm that all the tables have been created through migrate command (created in aws .config file) on the aws database. Just thought of sharing this in case this is helpful.

EDIT 2: so on the error page if I go down to the settings section I can see both id and password reflecting (pass in ******** form). However in the Traceback section I can see that password is None but rest of the info is there and this error is;

/opt/python/run/venv/lib64/python2.7/site-packages/psycopg2/ in connect
conn = _connect(dsn, connection_factory=connection_factory, async=async)

EDIT3: so I get everything from the db except for the password and I checked my env file found in /opt/python/current on aws ssh instance and found it had all the export settings correctly listed including the password.

To be more explicit, below I have mentioned the exception detail I get on traceback on the web page detail under

in connect
conn = _connect(dsn, connection_factory=connection_factory, async=async)

**Variable Value**

database 'xxx' - This is correct

items [('dbname', 'xxx'), This is correct
('user', 'xxxxx'), This is correct
('host', ''), This is correct
('port', '5432')]

k 'port'

kwargs {}

connection_factory None

dsn 'dbname=xxxx user=xxxx port=5432' This is correct

host '' This is correct

user 'xxxxx' This is correct

v '5432' async False

**password None** **THIS IT NOT CORRECT**

port '5432'

cursor_factory None


In your case I woould try going for

  1. Configure your Amazon RDS DB security group to allow access from the Amazon EC2 security group used by your Elastic Beanstalk application


Update: don't forget to backslash variables values like RDS_PASSWORD in os environment. Eg export RDS_PASSWORD="pa$$word" should become export RDS_PASSWORD="pa\$\$word"

to do this go to; on ssh ec2 instance and go to file


. This dir has one app directory which holds the django app and an env file. "nano env" and it shows lot of export statements go to the RDS_PASSWORD line and add the blackslash pass to it.

export RDS_PASSWORD="pa\$\$word". Save the file.

Then restart the app on aws and it works like a charm.