Django.db.utils.OperationalError: could not connect to server: Connection refused Ubuntu

На сервере Ubuntu. Сайт на хостинге, базу данных берет у хостинга. Почему то выскакивает Server Error (500) и в логах:

Traceback (most recent call last):
  File "/home/elite_stroy/www/venv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 35, in inner
    response = get_response(request)
  File "/home/elite_stroy/www/venv/lib/python3.5/site-packages/django/core/handlers/base.py", line 128, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/elite_stroy/www/venv/lib/python3.5/site-packages/django/core/handlers/base.py", line 126, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/elite_stroy/www/venv/lib/python3.5/site-packages/django/views/generic/base.py", line 69, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/elite_stroy/www/venv/lib/python3.5/site-packages/django/views/generic/base.py", line 89, in dispatch
    return handler(request, *args, **kwargs)
  File "/home/elite_stroy/www/venv/lib/python3.5/site-packages/django/views/generic/base.py", line 150, in get
    context = self.get_context_data(**kwargs)
  File "./main/views.py", line 75, in get_context_data
    cd['actions'] = models.Action.objects.actual().filter(is_main=True)[:3]
  File "./main/models.py", line 46, in actual
    for action in actions:
  File "/home/elite_stroy/www/venv/lib/python3.5/site-packages/django/db/models/query.py", line 272, in __iter__
    self._fetch_all()
  File "/home/elite_stroy/www/venv/lib/python3.5/site-packages/django/db/models/query.py", line 1179, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "/home/elite_stroy/www/venv/lib/python3.5/site-packages/django/db/models/query.py", line 53, in __iter__
    results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
  File "/home/elite_stroy/www/venv/lib/python3.5/site-packages/django/db/models/sql/compiler.py", line 1066, in execute_sql
    cursor = self.connection.cursor()
  File "/home/elite_stroy/www/venv/lib/python3.5/site-packages/django/db/backends/base/base.py", line 255, in cursor
    return self._cursor()
  File "/home/elite_stroy/www/venv/lib/python3.5/site-packages/django/db/backends/base/base.py", line 232, in _cursor
    self.ensure_connection()
  File "/home/elite_stroy/www/venv/lib/python3.5/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection
    self.connect()
  File "/home/elite_stroy/www/venv/lib/python3.5/site-packages/django/db/utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/home/elite_stroy/www/venv/lib/python3.5/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection
    self.connect()
  File "/home/elite_stroy/www/venv/lib/python3.5/site-packages/django/db/backends/base/base.py", line 194, in connect
    self.connection = self.get_new_connection(conn_params)
  File "/home/elite_stroy/www/venv/lib/python3.5/site-packages/django/db/backends/postgresql/base.py", line 168, in get_new_connection
    connection = Database.connect(**conn_params)
  File "/home/elite_stroy/www/venv/lib/python3.5/site-packages/psycopg2/__init__.py", line 130, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: 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?

Не понимаю причём тут локальный сервер и его база данных, если сайт уже на хостинге и берет данные от туда.

Back to Top