title: Can not connect to Postgresql running at different port using Python
body: <p>I have Postgres up and running on one of my machines. Its <code>pg_hba.conf</code> contains this string:</p>
  
  <pre><code>host    all             all             0.0.0.0/0               md5
  </code></pre>
  
  <p>And <code>postgresql.conf</code> contains these lines:</p>
  
  <pre><code>listen_addresses = '*'
  port = 5433
  </code></pre>
  
  <p>The machine on my local network has this IP address <code>192.168.234.137</code>. I try to connect to Postgres from another machine. If I use for example Navicat, then I can easily establish connection, so Postgres running at port 5433 is reachable. When, however, I try to connect to it using Python, I get an error message </p>
  
  <pre><code>Is the server running on host "192.168.234.137" and accepting
  TCP/IP connections on port 5433?
  </code></pre>
  
  <p>If I switch back to port 5432 - fix <code>postgresql.conf</code> and restart Postgres - then my Python script starts working. So it seems like Python (I tried psycopg2 and sqlalchemy) for some reason is bound by this <code>5432</code> port number and does not accept other port numbers. What is wrong with that and how can I fix it? I guess, simply changing <code>postgresql.conf</code> and restarting Postgres is not enough.</p>
  
  <p>PS.</p>
  
  <p>The code, I run, looks like so:</p>
  
  <pre><code>&gt;&gt;&gt; connection = psycopg2.connect(user = "postgres",
  ...                                   password = "postgres",
  ...                                   host = "192.168.234.137",
  ...                                   port = "5433",
  ...                                   database = "test")
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 5, in &lt;module&gt;
    File "C:\Python34\lib\site-packages\psycopg2-2.6.1-py3.4-win-amd64.egg   \psycopg2\__init__.py", line 164, in connect
      conn = _connect(dsn, connection_factory=connection_factory, async=async)
  psycopg2.OperationalError: could not connect to server: Connection timed out (0x0000274C/10060)
      Is the server running on host "192.168.234.137" and accepting
      TCP/IP connections on port 5433?
  </code></pre>