Error Heroku Django db postgres

I am trying to run my first django application, but I ran into this db error:

OperationalError: could not connect to server: Connection refused Is the server running on host "localhost" and accepting TCP/IP connections on port 5432? 

This happens whenever I try to sync, transfer or create a file upuperuser

I am setting the DATABASES variable as follows:

 DATABASES = {'default' : dj_database_url.config(default=os.environ["HEROKU_POSTGRESQL_OLIVE_URL"]) } 

Is there anything else I need to configure, or am I mistaken?

EDIT (SOLVES):

Thanks for helping me narrow down the problem, I found a solution.

Since this was the first time I turned to Herok, and the first time I used two django directories for scoops. I thought something like

 python manage.py syncdb # would be okay 

instead, my settings folder looked like

 .../settings base.py local.py production.py demo.py # ... 

I need to do

 python manage.py syncdb --app.settings.demo 
+1
python django heroku
source share
2 answers

Your syntax seems correct, try using DATABASE_URL after verifying that you have promoted HEROKU_POSTGRESQL_OLIVE_URL , although it should work even when it is not promoted.

 $ heroku pg:promote HEROKU_POSTGRESQL_OLIVE_URL 

and then:

 import dj_database_url DATABASES = { 'default': dj_database_url.config(default=os.getenv('DATABASE_URL')) } 

This setting should work. Make sure that you are working on the correct settings file. You can verify this by doing:

 $ heroku run python manage.py shell 

and then:

 >>> from django.conf import settings >>> print settings.DATABASES['default'] 

and check the result.

+1
source share

I had an error in .gitignore, and my local settings were set according to Herok by mistake.

This will also cause an error message.

0
source share

All Articles