title: Error when connecting to database with PostgreSQL and dblink_connect
body: <p>I have a strange problem with PostgreSQL and <code>dblink</code>.
  I have a remote PostgreSQL installation on amazon RDS 9.5.2 and a local PostgreSQL installation on Windows 10.</p>
  
  <p>I am trying to transfer data from the local installation to the remote installation using <code>dblink</code>. I am connected to the remote database with a query window opened from pgAdmin III. </p>
  
  <p>When connecting to the default <code>postgres</code> database I am successful:</p>
  
  <pre><code>select dblink_connect('dbname=postgres host=localhost user=postgres password=xxx');
  </code></pre>
  
  <p>However when I try to connect to any other database I get an error:</p>
  
  <pre><code>select dblink_connect('dbname=gti host=localhost user=postgres password=xxx');
  ERROR:  could not establish connection
  DETAIL:  FATAL:  database "gti" does not exist
  
  ********** Error **********
  
  ERROR: could not establish connection
  SQL state: 08001
  Detail: FATAL:  database "gti" does not exist
  </code></pre>
  
  <p>I have changed ownership to the <code>postgres</code> user for the database.</p>
  
  <p>But I am at my wits end what else to try.</p>
  
  <p>Edited. A screenshot from PgAdmin showing the databases both remote and local:
  <a href="http://i.stack.imgur.com/A2KmZ.jpg" rel="nofollow">pgAdmin screenshot</a></p>
  
  <p>Edited 2: I ran <code>select * from pg_database;</code> as requested:
  <a href="http://i.stack.imgur.com/otOba.jpg" rel="nofollow">Result set</a></p>
  
  <p>Edited 3: I set up a new PostgreSQL installation on another machine on our local network. Connected to Amazon and got exactly the same error.</p>
  
  <p>If I connect from PostgreSQL on this new pc to PostgreSQL on my pc in pgAdmin, open a query window and <code>dblink_connect</code> from there to the local instance I get no error. So it seems to be either an error when connecting to a database outside our network, or just Amazon specifically.</p>
  
  <p>Edited 4: If I add another user to my Local PostgreSQL instance and grant it superuser access, I cannot connect to my local instance from the amazon query window using <code>dblink</code>. I can however connect to my local instance using this new user from the other PostgreSQL on the local network.</p>