OperationalError : could not connect to server
See original GitHub issueSorry, I’m French I’m using Deepl. com for translation…
Impacted versions
-
Modoboa: I don’t have access to modoboa and I don’t know where to find the information in the terminal. But I installed it two weeks ago.
-
installer used: Yes/
-
Webserver: Nginx
-
Installed on a dedicated Debian 9.3 server
Steps to reproduce
After reboot
Current behavior
“Error with : Error as occured” when I visit https://mail.mondomaine.fr
Hello, I installed modoboa 2 weeks ago, everything worked perfectly but after a reboot, I no longer have access to webmail and I can no longer send or receive emails…
I have activated debug mode, here’s what it returns to me:
OperationalError at /
could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
Request Method:
GET
Request URL: https://mail.seedbt.fr/
Django Version: 1.10.8
Exception Type: OperationalError
Exception Value:
could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
Exception Location: /srv/modoboa/env/local/lib/python2.7/site-packages/psycopg2/__init__.py in connect, line 130
Python Executable: /usr/bin/uwsgi-core
Python Version: 2.7.13
Python Path:
['.',
'',
'/srv/modoboa/env/lib/python2.7',
'/srv/modoboa/env/lib/python2.7/plat-x86_64-linux-gnu',
'/srv/modoboa/env/lib/python2.7/lib-tk',
'/srv/modoboa/env/lib/python2.7/lib-old',
'/srv/modoboa/env/lib/python2.7/lib-dynload',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/srv/modoboa/env/local/lib/python2.7/site-packages',
'/srv/modoboa/env/lib/python2.7/site-packages']
Server time: | Sat, 13 Jan 2018 11:04:32 +0100
I add the trace back :
Environment:
Request Method: GET
Request URL: https://mail.seedbt.fr/
Django Version: 1.10.8
Python Version: 2.7.13
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.sites',
'django.contrib.staticfiles',
'reversion',
'ckeditor',
'ckeditor_uploader',
'rest_framework',
'rest_framework.authtoken',
'modoboa',
'modoboa.core',
'modoboa.lib',
'modoboa.admin',
'modoboa.relaydomains',
'modoboa.limits',
'modoboa.parameters',
'modoboa_amavis',
'modoboa_pdfcredentials',
'modoboa_postfix_autoreply',
'modoboa_sievefilters',
'modoboa_stats',
'modoboa_webmail',
'modoboa_contacts',
'webpack_loader')
Installed Middleware:
('x_forwarded_for.middleware.XForwardedForMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'modoboa.core.middleware.LocalConfigMiddleware',
'modoboa.lib.middleware.AjaxLoginRedirect',
'modoboa.lib.middleware.CommonExceptionCatcher',
'modoboa.lib.middleware.RequestCatcherMiddleware')
Traceback:
File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/core/handlers/exception.py" in inner
42. response = get_response(request)
File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/core/handlers/base.py" in _legacy_get_response
244. response = middleware_method(request)
File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/middleware/locale.py" in process_request
25. language = translation.get_language_from_request(request, check_path=i18n_patterns_used)
File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/utils/translation/__init__.py" in get_language_from_request
206. return _trans.get_language_from_request(request, check_path)
File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py" in get_language_from_request
516. lang_code = request.session.get(LANGUAGE_SESSION_KEY)
File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/contrib/sessions/backends/base.py" in get
68. return self._session.get(key, default)
File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/contrib/sessions/backends/base.py" in _get_session
207. self._session_cache = self.load()
File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/contrib/sessions/backends/db.py" in load
35. expire_date__gt=timezone.now()
File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/db/models/manager.py" in manager_method
85. return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/db/models/query.py" in get
379. num = len(clone)
File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/db/models/query.py" in __len__
238. self._fetch_all()
File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/db/models/query.py" in _fetch_all
1087. self._result_cache = list(self.iterator())
File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/db/models/query.py" in __iter__
54. results = compiler.execute_sql()
File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
833. cursor = self.connection.cursor()
File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/db/backends/base/base.py" in cursor
231. cursor = self.make_debug_cursor(self._cursor())
File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/db/backends/base/base.py" in _cursor
204. self.ensure_connection()
File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/db/backends/base/base.py" in ensure_connection
199. self.connect()
File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/db/utils.py" in __exit__
94. six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/db/backends/base/base.py" in ensure_connection
199. self.connect()
File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/db/backends/base/base.py" in connect
171. self.connection = self.get_new_connection(conn_params)
File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/db/backends/postgresql/base.py" in get_new_connection
176. connection = Database.connect(**conn_params)
File "/srv/modoboa/env/local/lib/python2.7/site-packages/psycopg2/__init__.py" in connect
130. conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
Exception Type: OperationalError at /
Exception Value: could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
Do you need the other logs displayed?
Thank you in advance for your help, I’m really annoyed…
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
django.db.utils.OperationalError Could not connect to server
You have something wrong trying to connect to your db like the username, the password or the databasename. Check that they are what...
Read more >How to Fix the OperationalError in Python - Rollbar
The OperationalError in Python is encountered when using the Psycopg library to indicate that incorrect database information was provided.
Read more >django.db.utils.OperationalError: could not connect to server
It seems, the communication with postgres is hardcoded in the app in a way that app assumes the db is on the same...
Read more >psycopg2.OperationalError: could not connect to ... - GitHub
I google this error in #277 but it seems that my error it is because of "Sorry... the password is also "anonymous" (no...
Read more >"psycopg2.OperationalError: could not connect to server ...
It looks like postgres is not running or not installed. Try: sudo service postgresql start.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I use debian stretch. I manually restart postgresql with each reboot. For the moment, that’s enough…
This is an year old issue which is closed but impacted my installation just today. Like @CooperBarrett mine is running on Debian Stretch so I tried restarting postgresql and sure enough it worked but am not sure what caused it to begin with and how to avoid it. Any suggestions will be hugely appreciated.