title: Node.js, PostgreSQL error: no pg_hba.conf entry for host
body: <p>I am following this article ((<a href="http://nodeexamples.com/2012/09/21/connecting-to-a-postgresql-database-from-node-js-using-the-pg-module/" rel="noreferrer">http://nodeexamples.com/2012/09/21/connecting-to-a-postgresql-database-from-node-js-using-the-pg-module/</a>). I have already deployed my app to heroku and currently using express, node.js, to try and connect to a PostgresSQL database in Heroku that I just installed. I get to the very end of the article and I use the command </p>
  
  <pre><code>node myfile.js
  </code></pre>
  
  <p>I get this error</p>
  
  <pre><code>error: no pg_hba.conf entry for host "...", user "...", database "...", ... 
  </code></pre>
  
  <p>How do I go about creating one and where in my app directory should I put it?</p>
  
  <p>Below is the entire error message. I changed the strings for IP address, user, and database but it looks basically just like it. </p>
  
  <pre><code>events.js:72
      throw er; // Unhandled 'error' event
            ^
  error: no pg_hba.conf entry for host "00.000.000.00", user "username", database "databasename", SSL off
  at Connection.parseE (/Users/user/workspace/MyApp/app/node_modules/pg/lib/connection.js:526:11)
  at Connection.parseMessage (/Users/user/workspace/MyApp/app/node_modules/pg/lib/connection.js:356:17)
  at Socket.&lt;anonymous&gt; (/Users/user/workspace/MyApp/app/node_modules/pg/lib/connection.js:105:22)
  at Socket.emit (events.js:95:17)
  at Socket.&lt;anonymous&gt; (_stream_readable.js:748:14)
  at Socket.emit (events.js:92:17)
  at emitReadable_ (_stream_readable.js:410:10)
  at emitReadable (_stream_readable.js:406:5)
  at readableAddChunk (_stream_readable.js:168:9)
  at Socket.Readable.push (_stream_readable.js:130:10)
  </code></pre>
  
  <hr>
  
  <p>Edit: I did some more research and found that the 'pg_hba.conf' file is in my   </p>
  
  <pre><code>/usr/local/var/postgres 
  </code></pre>
  
  <p>and I added this line into the 'pg_hba.conf' file</p>
  
  <pre><code># TYPE  DATABASE        USER            ADDRESS                 METHOD
   host   all             all                                     trust
  </code></pre>
  
  <p>also tried</p>
  
  <pre><code># TYPE  DATABASE        USER            ADDRESS                 METHOD
  host   all             all              0.0.0.0/0               md5
  </code></pre>
  
  <p>but it keeps saying there is no entry for my host, user, database, etc...
  is my 'pg_hba.conf' syntax wrong in any way?</p>