OperationalError Could Not Connect To Server -- Django/Heroku/AWS/Postgres

0

Im having an odd problem when trying to run my website on my local machine. If I type in python manage.py runserver, I get the following error and my site won't load.

I tried to restart my Postgres database on my local machine and restarted the computer but having the same problems.

My site is built in Python/Django hosted on Heroku with files served via Cloudfront/AWS.

System check identified 1 issue (0 silenced).
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x072D7780>
Traceback (most recent call last):
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 216, in ensure_connection
    self.connect()
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 194, in connect
    self.connection = self.get_new_connection(conn_params)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\postgresql\base.py", line 168, in get_new_connection
    connection = Database.connect(**conn_params)
  File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\psycopg2\__init__.py", line 130, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: could not connect to server: Connection timed out (0x0000274C/10060)
        Is the server running on host "ec2-107-20-188-239.compute-1.amazonaws.com" (107.20.188.239) and accepting
        TCP/IP connections on port 5432?


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\runserver.py", line 123, in inner_run
    self.check_migrations()
  File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py", line 427, in check_migrations
    executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
  File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\migrations\executor.py", line 18, in __init__
    self.loader = MigrationLoader(self.connection)
  File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\migrations\loader.py", line 49, in __init__
    self.build_graph()
  File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\migrations\loader.py", line 206, in build_graph
    self.applied_migrations = recorder.applied_migrations()
  File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\migrations\recorder.py", line 61, in applied_migrations
    if self.has_table():
  File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\migrations\recorder.py", line 44, in has_table
    return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor())
  File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 255, in cursor
    return self._cursor()
  File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 232, in _cursor
    self.ensure_connection()
  File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 216, in ensure_connection
    self.connect()
  File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 216, in ensure_connection
    self.connect()
  File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 194, in connect
    self.connection = self.get_new_connection(conn_params)
  File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\postgresql\base.py", line 168, in get_new_connection
    connection = Database.connect(**conn_params)
  File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\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 timed out (0x0000274C/10060)
        Is the server running on host "ec2-107-20-188-239.compute-1.amazonaws.com" (107.20.188.239) and accepting
        TCP/IP connections on port 5432?
python
django
postgresql
amazon-web-services
asked on Stack Overflow Apr 24, 2018 by John Rogerson

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0