Reputation: 3
This is my settings.py file in my Django project. OS : Windows, hosting : localhost
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'postgres',
'USER': 'JESS',
'PASSWORD': 'dreamhost',
'HOST': 'localhost',
'PORT': '5432',
}
}
I followed instructions from this blog in installing PostgreSQL and psycopg2
http://shivul.wordpress.com/2010/05/07/installing-django-with-postgresql-on-windows-and-ubuntu/
and when running python manage.py syncdb
I get the following error:
OperationalError: Could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432
Could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432
I even tried to edit settings through pgadmin3 application in PostgreSQL installation files, it even throws the same error
Could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432
Could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432
I looked through similar questions in stackoverflow and internet, everything is outdated or not working.
Upvotes: 0
Views: 3473
Reputation: 341
I bumped into the exact same message recently but the cause/solution for my problem was different. I am not exactly sure what screwed me up but I think it was when I was seeing what happens when you run the clearsessions function in manage.py.
In the end I needed to restart the postgresql service.
To do this (Windows 7),
(you can also search for 'View local services' in the start menu)
In the services window: 4. find postgresql-XXXX. 5. Click on it and start it if it is stopped.
If it is already running you might as well restart it since your there and see if it helps. My issue was specifically that the service was not restarting on boot.
Upvotes: 0
Reputation: 324445
Your server is listening only on IPv4, but localhost
is resolving to both an IPv4 and IPv6 address on your host.
Use 127.0.0.1
instead of localhost
to force an IPv4 connection, or edit postgresql.conf
to tell your PostgreSQL to listen on IPv6 too. Show the listen_addresses
line of postgresql.conf
for advice on that, along with the output of select version()
.
Upvotes: 4