Skip to content

Instantly share code, notes, and snippets.

@Bind
Created July 28, 2014 18:23
Show Gist options
  • Save Bind/caa2646e1335d3d9dec2 to your computer and use it in GitHub Desktop.
Save Bind/caa2646e1335d3d9dec2 to your computer and use it in GitHub Desktop.
django.db.utils.OperationalError
OperationalError: could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (fe80::1) and accepting
TCP/IP connections on port 5432?
Traceback (most recent call last)
File "/Users/dougbinder/sites/env/fintech/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", line 67, in __call__
return self.application(environ, start_response)
File "/Users/dougbinder/sites/env/fintech/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 206, in __call__
response = self.get_response(request)
File "/Users/dougbinder/sites/env/fintech/lib/python2.7/site-packages/django/core/handlers/base.py", line 194, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "/Users/dougbinder/sites/env/fintech/lib/python2.7/site-packages/django/core/handlers/base.py", line 229, in handle_uncaught_exception
return debug.technical_500_response(request, *exc_info)
File "/Users/dougbinder/sites/env/fintech/lib/python2.7/site-packages/django/core/handlers/base.py", line 112, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/dougbinder/sites/env/fintech/lib/python2.7/site-packages/django/views/generic/base.py", line 69, in view
return self.dispatch(request, *args, **kwargs)
File "/Users/dougbinder/sites/env/fintech/lib/python2.7/site-packages/braces/views/_access.py", line 55, in dispatch
if not request.user.is_authenticated():
File "/Users/dougbinder/sites/env/fintech/lib/python2.7/site-packages/django/utils/functional.py", line 213, in inner
self._setup()
File "/Users/dougbinder/sites/env/fintech/lib/python2.7/site-packages/django/utils/functional.py", line 298, in _setup
self._wrapped = self._setupfunc()
File "/Users/dougbinder/sites/env/fintech/lib/python2.7/site-packages/django/contrib/auth/middleware.py", line 18, in <lambda>
request.user = SimpleLazyObject(lambda: get_user(request))
File "/Users/dougbinder/sites/env/fintech/lib/python2.7/site-packages/django/contrib/auth/middleware.py", line 10, in get_user
request._cached_user = auth.get_user(request)
File "/Users/dougbinder/sites/env/fintech/lib/python2.7/site-packages/django/contrib/auth/__init__.py", line 140, in get_user
user_id = request.session[SESSION_KEY]
File "/Users/dougbinder/sites/env/fintech/lib/python2.7/site-packages/django/contrib/sessions/backends/base.py", line 47, in __getitem__
return self._session[key]
File "/Users/dougbinder/sites/env/fintech/lib/python2.7/site-packages/django/contrib/sessions/backends/base.py", line 173, in _get_session
self._session_cache = self.load()
File "/Users/dougbinder/sites/env/fintech/lib/python2.7/site-packages/django/contrib/sessions/backends/db.py", line 20, in load
expire_date__gt=timezone.now()
File "/Users/dougbinder/sites/env/fintech/lib/python2.7/site-packages/django/db/models/manager.py", line 151, in get
return self.get_queryset().get(*args, **kwargs)
File "/Users/dougbinder/sites/env/fintech/lib/python2.7/site-packages/django/db/models/query.py", line 304, in get
num = len(clone)
File "/Users/dougbinder/sites/env/fintech/lib/python2.7/site-packages/django/db/models/query.py", line 77, in __len__
self._fetch_all()
File "/Users/dougbinder/sites/env/fintech/lib/python2.7/site-packages/django/db/models/query.py", line 857, in _fetch_all
self._result_cache = list(self.iterator())
File "/Users/dougbinder/sites/env/fintech/lib/python2.7/site-packages/django/db/models/query.py", line 220, in iterator
for row in compiler.results_iter():
File "/Users/dougbinder/sites/env/fintech/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 713, in results_iter
for rows in self.execute_sql(MULTI):
File "/Users/dougbinder/sites/env/fintech/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 785, in execute_sql
cursor = self.connection.cursor()
File "/Users/dougbinder/sites/env/fintech/lib/python2.7/site-packages/debug_toolbar/panels/sql/tracking.py", line 45, in cursor
return state.Wrapper(connection._djdt_cursor(), connection, panel)
File "/Users/dougbinder/sites/env/fintech/lib/python2.7/site-packages/django/db/backends/__init__.py", line 160, in cursor
cursor = self.make_debug_cursor(self._cursor())
File "/Users/dougbinder/sites/env/fintech/lib/python2.7/site-packages/django/db/backends/__init__.py", line 132, in _cursor
self.ensure_connection()
File "/Users/dougbinder/sites/env/fintech/lib/python2.7/site-packages/django/db/backends/__init__.py", line 127, in ensure_connection
self.connect()
File "/Users/dougbinder/sites/env/fintech/lib/python2.7/site-packages/django/db/utils.py", line 99, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/Users/dougbinder/sites/env/fintech/lib/python2.7/site-packages/django/db/backends/__init__.py", line 127, in ensure_connection
self.connect()
File "/Users/dougbinder/sites/env/fintech/lib/python2.7/site-packages/django/db/backends/__init__.py", line 115, in connect
self.connection = self.get_new_connection(conn_params)
File "/Users/dougbinder/sites/env/fintech/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 114, in get_new_connection
return Database.connect(**conn_params)
File "/Users/dougbinder/sites/env/fintech/lib/python2.7/site-packages/psycopg2/__init__.py", line 164, in connect
conn = _connect(dsn, connection_factory=connection_factory, async=async)
OperationalError: could not connect to server: Connection refused Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? could not connect to server: Connection refused Is the server running on host "localhost" (fe80::1) and accepting TCP/IP connections on port 5432?
The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error.
To switch between the interactive traceback and the plaintext one, you can click on the "Traceback" headline. From the text traceback you can also create a paste of it. For code execution mouse-over the frame you want to debug and click on the console icon on the right side.
You can execute arbitrary Python code in the stack frames and there are some extra helpers available for introspection:
dump() shows all variables in the frame
dump(obj) dumps all that's known about the object
Brought to you by DON'T PANIC, your friendly Werkzeug powered traceback interpreter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment