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:
DATABASES = {
'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
**Variable**
my_list
**Value**
Error in formatting: OperationalError: fe_sendauth: no password supplied
**request**
<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/__init__.py 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
/opt/python/run/venv/lib64/python2.7/site-packages/psycopg2/init.py 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', 'xxxxxxx.rds.amazonaws.com'), This is correct
('port', '5432')]
k 'port'
kwargs {}
connection_factory None
dsn 'dbname=xxxx user=xxxx host=xxxx.rds.amazonaws.com port=5432' This is correct
host 'xxxx.rds.amazonaws.com' This is correct
user 'xxxxx' This is correct
v '5432' async False
**password None** **THIS IT NOT CORRECT**
port '5432'
cursor_factory None
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-rds.html
In your case I woould try going for
- Configure your Amazon RDS DB security group to allow access from the Amazon EC2 security group used by your Elastic Beanstalk application
part
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
/opt/python/current
. 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.