title: Getting error 'django.db.utils.OperationalError' when doing 'python manage.py migrate' in Django 1.9 with PostgreSQL 9.5
body: <p>I am new to programming and learning the web development. I have installed the 
   -Django 1.9 
   -postgresql 9.5
   -psycopg2(using whl file) db api for the postgresql on Windows 7 os. </p>
  
  <p>I have set up the database connection in my settings.py file for my project as following. </p>
  
  <pre><code> DATABASES = 
  { 'default': 
  { 'ENGINE': 'django.db.backends.postgresql', 
  'NAME': 'Test', 
  'User': 'postgres', 
  'PASSWORD': 'admin', 
  'HOST': 'localhost', 
  'PORT': '5432', 
  } 
  </code></pre>
  
  <p>but when I am running migrate I am running in to following problem. I want to connect the postgres to my django
  See the error below: </p>
  
  <pre><code>Traceback (most recent call last):
   File "C:\Users\agarwal.s.13\AppData\Local\Programs\Python\Python35-32\lib\site
  -packages\django\db\backends\base\base.py", line 199, in ensure_connection
  self.connect()
   File "C:\Users\agarwal.s.13\AppData\Local\Programs\Python\Python35-32\lib\site
  -packages\django\db\backends\base\base.py", line 171, in connect
  self.connection = self.get_new_connection(conn_params)
    File "C:\Users\agarwal.s.13\AppData\Local\Programs\Python\Python35-32\lib\site
  -packages\django\db\backends\postgresql\base.py", line 175, in get_new_connection
      connection = Database.connect(**conn_params)
    File "C:\Users\agarwal.s.13\AppData\Local\Programs\Python\Python35-32\lib\site
  -packages\psycopg2\__init__.py", line 164, in connect
      conn = _connect(dsn, connection_factory=connection_factory, async=async)psycopg2.OperationalError
  The above exception was the direct cause of the following exception:
  
  Traceback (most recent call last):
    File "manage.py", line 10, in &lt;module&gt;
     execute_from_command_line(sys.argv)
   File "C:\Users\agarwal.s.13\AppData\Local\Programs\Python\Python35-32\lib\site
  -packages\django\core\management\__init__.py", line 353, in         execute_from_command_line
      utility.execute()
     File "C:\Users\agarwal.s.13\AppData\Local\Programs\Python\Python35-32\lib\site
   -packages\django\core\management\__init__.py", line 345, in execute
  self.fetch_command(subcommand).run_from_argv(self.argv)
    File "C:\Users\agarwal.s.13\AppData\Local\Programs\Python\Python35-32\lib\site
   -packages\django\core\management\base.py", line 348, in run_from_argv
  self.execute(*args, **cmd_options)
     File "C:\Users\agarwal.s.13\AppData\Local\Programs\Python\Python35-32\lib\site
   -packages\django\core\management\base.py", line 399, in execute
  output = self.handle(*args, **options)
    File "C:\Users\agarwal.s.13\AppData\Local\Programs\Python\Python35-32\lib\site
   -packages\django\core\management\commands\migrate.py", line 89, in handle
  executor = MigrationExecutor(connection, self.migration_progress_callback)
    File "C:\Users\agarwal.s.13\AppData\Local\Programs\Python\Python35-32\lib\site
  -packages\django\db\migrations\executor.py", line 20, in __init__
  self.loader = MigrationLoader(self.connection)
    File "C:\Users\agarwal.s.13\AppData\Local\Programs\Python\Python35-32\lib\site
  -packages\django\db\migrations\loader.py", line 49, in __init__
  self.build_graph()
    File "C:\Users\agarwal.s.13\AppData\Local\Programs\Python\Python35-32\lib\site
  -packages\django\db\migrations\loader.py", line 176, in build_graph
  self.applied_migrations = recorder.applied_migrations()
    File "C:\Users\agarwal.s.13\AppData\Local\Programs\Python\Python35-32\lib\site
  -packages\django\db\migrations\recorder.py", line 65, in applied_migrations
  self.ensure_schema()
    File "C:\Users\agarwal.s.13\AppData\Local\Programs\Python\Python35-32\lib\site
  -packages\django\db\migrations\recorder.py", line 52, in ensure_schema
  if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()):
    File "C:\Users\agarwal.s.13\AppData\Local\Programs\Python\Python35-32\lib\site
  -packages\django\db\backends\base\base.py", line 231, in cursor
  cursor = self.make_debug_cursor(self._cursor())
    File "C:\Users\agarwal.s.13\AppData\Local\Programs\Python\Python35-32\lib\site
  -packages\django\db\backends\base\base.py", line 204, in _cursor
  self.ensure_connection()
    File "C:\Users\agarwal.s.13\AppData\Local\Programs\Python\Python35-32\lib\site
  -packages\django\db\backends\base\base.py", line 199, in ensure_connection
  self.connect()
    File "C:\Users\agarwal.s.13\AppData\Local\Programs\Python\Python35-32\lib\site
    -packages\django\db\utils.py", line 95, in __exit__six.reraise(dj_exc_type, dj_exc_value, traceback)
    File "C:\Users\agarwal.s.13\AppData\Local\Programs\Python\Python35-32\lib\site
   -packages\django\utils\six.py", line 685, in reraise
  raise value.with_traceback(tb)
    File "C:\Users\agarwal.s.13\AppData\Local\Programs\Python\Python35-32\lib\site
    -packages\django\db\backends\base\base.py", line 199, in ensure_connection
  self.connect()
    File "C:\Users\agarwal.s.13\AppData\Local\Programs\Python\Python35-32\lib\site
  -packages\django\db\backends\base\base.py", line 171, in connect
  self.connection = self.get_new_connection(conn_params)
    File "C:\Users\agarwal.s.13\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\db\backends\postgresql\base.py", line 175, in get_new_connection
     connection = Database.connect(**conn_params)
    File "C:\Users\agarwal.s.13\AppData\Local\Programs\Python\Python35-32\lib\site
  -packages\psycopg2\__init__.py", line 164, in connect
  conn = _connect(dsn, connection_factory=connection_factory, async=async)
  django.db.utils.OperationalError
  </code></pre>
  
  <p>I have checked with python script the psycopg2 is able to connect the database in postgresql but when I am running migrate from django project, its not working and getting above error.</p>