title: Postgresql remote access no pg_hba.conf entry for host
body: <p>I'm trying to get remote access to postgresql, installed on a server with IP A.A.A.A. There are two servers which one them has IP A.A.A.A, where postgresql has been installed on; and the other one has IP B.B.B.B.</p>
  
  <p>I've edited <code>/etc/postgresql/10/main/pg_hba.conf</code> and added the following lines</p>
  
  <pre><code>host my_db db_user B.B.B.B/32 md5
  host my_db db_user A.A.A.A/32 md5
  </code></pre>
  
  <p>I've also edited <code>/etc/postgresql/10/main/postgresql.conf</code> and set <code>listen_addresses</code> to <code>'*'</code>, like this:</p>
  
  <pre><code>#---------------------------------------------------------------------    
  ---------
  # CONNECTIONS AND AUTHENTICATION
  #------------------------------------------------------------------------------
  
  # - Connection Settings -
  
  listen_addresses = '*'          # what IP address(es) to listen on;
                                      # comma-separated list of     addresses;
                                      # defaults to 'localhost'; use '*' for all
                                      # (change requires restart)
  port = 5432                             # (change requires restart)
  max_connections = 100                   # (change requires restart)
  </code></pre>
  
  <p>I have also allowed connections through port 5432 in ufw:</p>
  
  <pre><code>5432                       ALLOW       Anywhere                  
  5432 (v6)                  ALLOW       Anywhere (v6)             
  </code></pre>
  
  <p>Now, if I am in server A (where postgres is installed) and do psql <code>"postgresql://db_user:password@A.A.A.A:5432/my_db"</code> it connects fine. But if I do it from the server with IP B.B.B.B I get this error:</p>
  
  <pre><code>psql: FATAL:  no pg_hba.conf entry for host "B.B.B.B", user "db_user", database "my_db", SSL on
  FATAL:  no pg_hba.conf entry for host "B.B.B.B", user "db_user", database "my_db", SSL off
  </code></pre>
  
  <p>I really don't understand where the mistake is. Both entries in <code>pg_hba.conf</code> look the same, but one works and the other doesn't.</p>