title: Debugging a PostgreSQL Remote Connection
body: <p>I'm having issues connecting to my PostgreSQL database from an online source.</p>
  
  <p>PostgreSQL seems to be setup up fine it is running on it's default port 5432 and the postgresql.conf has the following line</p>
  
  <pre><code>listen_addresses = '*'
  </code></pre>
  
  <p>And the pg_hba.conf has the following</p>
  
  <pre><code>host    dbname    usname    all    md5
  </code></pre>
  
  <p>I can connect to the PostgreSQL database from a different machine using the following credentials in pgadmin</p>
  
  <pre><code>Name              local
  Host              192.xx.xx.xx
  Port              5432
  Maintenance DB    dbname
  Username          usname
  Password          psword
  </code></pre>
  
  <p>Using these I can connect perfectly it seems to work fine.</p>
  
  <p>Then I forwarded the port 192.xx.xx.xx:5432 on the ADSL router and checked it using the public IP address 197.xx.xx.xx (visible to the internet IP)
  <a href="http://www.canyouseeme.org/" rel="nofollow">http://www.canyouseeme.org/</a>
  Where I can see the port was forwarded ok.</p>
  
  <p>However when I try to connect using</p>
  
  <pre><code>Name              online
  Host              197.xx.xx.xx
  Port              5432
  Maintenance DB    dbname
  Username          usname
  Password          psword
  </code></pre>
  
  <p>I get the server doesn't listen error message</p>
  
  <pre><code>could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "197.xx.xx.xx" and accepting TCP/IP connections on port 5432?
  </code></pre>
  
  <p>Why is this? Do I need to add an extra step to making it accept connections through port forwarding?</p>