title: Postgres: 'role does not exist' using dblink, but it does
body: <p>So this is super strange.  I'm trying to do a simple select using dblink as such:</p>
  
  <blockquote>
    <p>SELECT * FROM dblink('dbname=my_db_name, user=my_user,
    password=password, hostaddr=127.0.0.1', 'SELECT action, object,
    created_at, id FROM my_table') AS de(ACTION VARCHAR, OBJECT VARCHAR,
    created_at TIMESTAMP, id INT)</p>
  </blockquote>
  
  <p>And I immediately am getting an error message of: </p>
  
  <blockquote>
    <p>PG::SqlclientUnableToEstablishSqlconnection: ERROR:  could not</p>
    
    <p>establish connection DETAIL:  FATAL:  role "my_user," does not exist</p>
  </blockquote>
  
  <p>But if I connect to psql locally and print out the list of users using \du you'll see it's listed:</p>
  
  <pre><code>                               List of roles
     Role name   |                   Attributes                   | Member of 
  ---------------+------------------------------------------------+-----------
   MyName        | Superuser, Create role, Create DB, Replication | {}
   my_user       | Create DB                                      | {}
  </code></pre>
  
  <p>I'm really at a loss as to how to fix this, googling hasn't helped me much at all either.  Any thoughts as to why it's giving me this error message?</p>
  
  <p>When I connect using my superuser account I don't need to specify a password and the dblink runs fine, so I'm quite confused.  Here is by pg_hba.conf:</p>
  
  <pre><code>local   all             all                                     trust
  local   all             all                                     md5
  
  host    all             all             192.168.33.1/24         trust
  
  # IPv4 local connections:
  host    all             all             127.0.0.1/32            trust
  host    all             all             127.0.0.1/32            md5
  
  # IPv6 local connections:
  host    all             all             ::1/128                 trust
  host    all             all             ::1/128                 md5
  </code></pre>
  
  <p>Thanks in advance!</p>