Reputation: 12388
I am trying to get my first django app up, but I'm running 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 syncdb, migrate, or createsuperuser
I am configuring my DATABASES variable like:
DATABASES = {'default' : dj_database_url.config(default=os.environ["HEROKU_POSTGRESQL_OLIVE_URL"]) }
Is there something else I need to configure or am doing wrong?
EDIT (SOLVED):
Thanks for helping me narrow down the problem, I've found the solution.
Since this was the first time I deployed to heroku and the first time I used the two scoops django directory format. I thought doing something like
python manage.py syncdb # would be okay
instead beause my settings folder looks like
.../settings
base.py
local.py
production.py
demo.py
# ...
I need to do
python manage.py syncdb --app.settings.demo
Upvotes: 2
Views: 2641
Reputation: 1633
I had an error in .gitignore and my local settings were getting set by Heroku by mistake.
This will also cause this error message message.
Upvotes: 0
Reputation: 165340
Your syntax seems right, try using DATABASE_URL
after verifying you promoted HEROKU_POSTGRESQL_OLIVE_URL
, although it should work even when 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 setup should be working. Else, check that you are working on the right settings file. You can verify this by running:
$ heroku run python manage.py shell
and then:
>>> from django.conf import settings
>>> print settings.DATABASES['default']
and verify result.
Upvotes: 1