title: psql: no pg_hba.conf entry for host, could not connect to server
body: <p>I'm trying to connect to a remote psql server and I get the below error:</p>
  
  <pre><code>psql: FATAL: no pg_hba.conf entry for host "IP_Address", user "root", database "testdb", SSL off
  psql: could not connect to server: No such file or directory
  </code></pre>
  
  <p>PostgreSQL server log:</p>
  
  <pre><code>t[2020-04-15 16:42:30.634 +03] p[19813] hp[&lt;IP_Address&gt;(51448)] db[[unknown]] u[[unknown]] a[[unknown]] tx[0:] s[5e970f46.4d65:1] e[00000] i[] LOG:  connection received: host=&lt;IP_Address&gt; port=51448
  
  t[2020-04-15 16:42:30.636 +03] p[19813] hp[&lt;IP_Address&gt;(51448)] db[testdb] u[root] a[[unknown]] tx[0:5/276857] s[5e970f46.4d65:2] e[28000] i[authentication] FATAL:  no pg_hba.conf entry for host "&lt;IP_Address&gt;", user "root", database "testdb", SSL off
  </code></pre>
  
  <p>Psql server receives the connection but cant authenticate the user for db but root user have all privileges on testdb.</p>
  
  <p>I have the following entry in my hba conf:</p>
  
  <pre><code>host     testdb          root          &lt;IP_Address/32&gt;          trust
  </code></pre>
  
  <p>I have the following lines in my bash script which connects to remote psql and insert required values.</p>
  
  <pre><code>database="testdb"
  result=`df -h`
  hostname=`hostname`
  psql -h &lt;IP_Address&gt; -U root -d $database -c "INSERT INTO os.info VALUES ('$hostname','$result')"
  </code></pre>
  
  <p>The user root in psql hasn't got password. Script is working fine in local psql server .</p>