简体   繁体   中英

connect heroku django app with ec2 postgres database

I have a django app running on heroku. It works well with the heroku provided 5 mb database.

I have an ec2 instance, where I have installed postgresql database and have setup the database based on the following answer Setting Up Django and PostgreSQL on two different EC2 instances

I have added custom TCP port 5432 in Security Groups for PG.

To connect my heroku app with postgresql database on EC2, I try the following

heroku config:add DATABASE_URL=\
postgres://my_database_name:my_database_password@\
<Public_DNS>:<PORT>/my_user_name

Having done this, I try to do heroku run python manage.py syncdb and then I receive the error:

psycopg2.OperationalError: could not connect to server: Connection timed out
    Is the server running on host "......compute-1.amazonaws.com" and accepting
    TCP/IP connections on port 5432?

Please let me know, what is going wrong?

Check whether host's still available. I think that could be the issue.

what does heroku config | grep HEROKU_POSTGRESQL heroku config | grep HEROKU_POSTGRESQL show ?

Does it give the same host as seen in

"could not connect to server: Connection timed out
    Is the server running on host "......compute-1.amazonaws.com"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM