Reputation: 5473
How can i connect my Heroku app to a Postgres database hosted on amazon EC2 without any paid addon? I am using Django and my current code is:
DATABASES = {'default': dj_database_url.config(default='postgres://postgres:xxx@publicip/dbname')}
but i am still getting connected to my local database instead..
Upvotes: 1
Views: 768
Reputation: 11342
Your application is likely connecting to a free Postgres database as defined by the DATABASE_URL
environment variable. You should use config:set
to set that variable to point to your remote database, and ensure your code connects to that DATABASE_URL
:
$ heroku config:set DATABASE_URL=postgres://postgres:xxx@publicip/dbname --app your_app
See also:
Upvotes: 2