[英]Remote postgres database on Heroku app
How can i connect my Heroku app to a Postgres database hosted on amazon EC2 without any paid addon? 我如何将Heroku应用程序连接到Amazon EC2上托管的Postgres数据库,而无需任何付费插件? I am using Django and my current code is: 我正在使用Django,当前代码为:
DATABASES = {'default': dj_database_url.config(default='postgres://postgres:xxx@publicip/dbname')}
but i am still getting connected to my local database instead.. 但是我仍然可以连接到本地数据库。
Your application is likely connecting to a free Postgres database as defined by the DATABASE_URL
environment variable. 您的应用程序可能已连接到由DATABASE_URL
环境变量定义的免费Postgres数据库。 You should use config:set
to set that variable to point to your remote database, and ensure your code connects to that DATABASE_URL
: 您应该使用config:set
将该变量设置为指向您的远程数据库,并确保您的代码连接到该DATABASE_URL
:
$ heroku config:set DATABASE_URL=postgres://postgres:xxx@publicip/dbname --app your_app
See also: 也可以看看:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.