簡體   English   中英

將Heroku django應用程序與ec2 postgres數據庫連接

[英]connect heroku django app with ec2 postgres database

我在heroku上運行了django應用。 與heroku提供的5 mb數據庫一起使用時效果很好。

我有一個ec2實例,我在其中安裝了postgresql數據庫,並根據以下答案設置了數據庫: 在兩個不同的EC2實例上設置Django和PostgreSQL

我在PG的安全組中添加了自定義TCP端口5432。

要將heroku應用程序與EC2上的postgresql數據庫連接,請嘗試以下操作

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

完成此操作后,我嘗試在heroku run python manage.py syncdb ,然后收到錯誤消息:

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?

請讓我知道,怎么了?

檢查主機是否仍然可用。 我認為這可能是問題。

heroku config | grep HEROKU_POSTGRESQL什么? heroku config | grep HEROKU_POSTGRESQL顯示嗎?

它提供的主機與

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM