我有一个在 heroku 上运行的 django 应用程序。它适用于 heroku 提供的 5 mb 数据库。
我有一个 ec2 实例,我在其中安装了 postgresql 数据库并根据以下答案设置了数据库 Setting Up Django and PostgreSQL on two different EC2 instances
我在 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 配置 | grep HEROKU_POSTGRESQL
显示 ?
它给出的主机是否与在
中看到的相同"could not connect to server: Connection timed out
Is the server running on host "......compute-1.amazonaws.com"
关于python - 将 heroku django 应用程序与 ec2 postgres 数据库连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14542866/