title: Connection refused to Postgresql
body: <p>Here is the code I wrote for connecting Postgresql using psycopg2. My psql and pgadminIII is also running.</p>
  
  <pre><code>import psycopg2
  
  connection = psycopg2.connect(dbname="gps_heatmap",user="postgres",host="localhost",password="1234")
  cursor = connection.cursor()
  
  cursor.execute("DROP TABLE IF EXISTS roads")
  cursor.execute("CREATE TABLE roads (" +
                     "id SERIAL PRIMARY KEY," +
                     "name VARCHAR," + 
                     "centerline GEOMETRY)")
  cursor.execute("CREATE INDEX ON roads USING GIST(centerline)")
  
  connection.commit()
  </code></pre>
  
  <p>But following error comes:</p>
  
  <pre><code> OperationalError                          Traceback (most recent call last)
      &lt;ipython-input-14-03e3f214b83e&gt; in &lt;module&gt;()
            1 import psycopg2
            2 
      ----&gt; 3 connection = psycopg2.connect(dbname="gps_heatmap",user="postgres",host="localhost",password="1234",port="5432")
            4 cursor = connection.cursor()
            5 
  
  C:\Users\*******\Anaconda3\lib\site-packages\psycopg2\__init__.py in connect(dsn, database, user, password, host, port, connection_factory, cursor_factory, async, **kwargs)
      162                 for (k, v) in items])
      163 
  --&gt; 164     conn = _connect(dsn, connection_factory=connection_factory, async=async)
      165     if cursor_factory is not None:
      166         conn.cursor_factory = cursor_factory
  
  OperationalError: could not connect to server: Connection refused (0x0000274D/10061)
      Is the server running on host "localhost" (::1) and accepting
      TCP/IP connections on port 5432?
  could not connect to server: Connection refused (0x0000274D/10061)
      Is the server running on host "localhost" (127.0.0.1) and accepting
      TCP/IP connections on port 5432?
  </code></pre>
  
  <p>I edited the pg_hbf.conf as:
   host    all   all    0.0.0.0/0     md5</p>
  
  <p>Again,same error repeated</p>