1

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..

2
  • For some platforms Heroku seems to override the usual connection configuration and inject its own config. You may need to look up Heroku-specific documentation on Django to see how it configures connections in Django. Commented Jun 6, 2014 at 0:53
  • ill try reading the documentation thanks Commented Jun 6, 2014 at 19:53

1 Answer 1

2

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:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.