title: (node:5321) UnhandledPromiseRejectionWarning: error: password authentication failed for user "postgres"
body: <p>I'm taking a web dev course and currently coding along with this video: <a href="https://www.youtube.com/watch?v=RhJwCD0tT5Y" rel="nofollow noreferrer">https://www.youtube.com/watch?v=RhJwCD0tT5Y</a></p>
  <p>I've made a github repository for the app which can be found here: <a href="https://github.com/JohnTarvis/node-pg-demo" rel="nofollow noreferrer">https://github.com/JohnTarvis/node-pg-demo</a></p>
  <p>The same error comes up whether I'm logged in as my normal user name, postgres or root.</p>
  <p>this is the full error:</p>
  <pre><code>(node:6267) UnhandledPromiseRejectionWarning: error: password authentication failed for user &quot;postgres&quot;
      at Parser.parseErrorMessage (/home/tarvis/Documents/sb-exercises/codealong/express-pg-intro-demo/VideoCode/pg-intro/node_modules/pg-protocol/dist/parser.js:287:98)
      at Parser.handlePacket (/home/tarvis/Documents/sb-exercises/codealong/express-pg-intro-demo/VideoCode/pg-intro/node_modules/pg-protocol/dist/parser.js:126:29)
      at Parser.parse (/home/tarvis/Documents/sb-exercises/codealong/express-pg-intro-demo/VideoCode/pg-intro/node_modules/pg-protocol/dist/parser.js:39:38)
      at Socket.&lt;anonymous&gt; (/home/tarvis/Documents/sb-exercises/codealong/express-pg-intro-demo/VideoCode/pg-intro/node_modules/pg-protocol/dist/index.js:11:42)
      at Socket.emit (events.js:314:20)
      at addChunk (_stream_readable.js:297:12)
      at readableAddChunk (_stream_readable.js:272:9)
      at Socket.Readable.push (_stream_readable.js:213:10)
      at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
  (node:6267) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
  (node:6267) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
  
  </code></pre>
  <p>This is the db.js file</p>
  <pre><code>const { Client } = require(&quot;pg&quot;);
  
  let DB_URI;
  
  // If we're running in test &quot;mode&quot;, use our test db
  // Make sure to create both databases!
  if (process.env.NODE_ENV === &quot;test&quot;) {
    DB_URI = &quot;postgresql:///usersdb_test&quot;;
  } else {
    DB_URI = &quot;postgresql:///usersdb&quot;;
  }
  
  let db = new Client({
    connectionString: DB_URI
  });
  
  db.connect();
  
  module.exports = db;
  </code></pre>
  <p>I've been googling this all day and most answers involve changing the code to add user credentials but that shouldn't be necessary if the instructor doesn't need to do this.  Is there some setting in postgres that I need to change?</p>
  <p>A lot of answers involve changing the file pg_hba.conf</p>
  <p>I cannot find this file on my system.  Do I need to add it?</p>
  <p>(edit: located the file.  What do I need to change here?)</p>
  <p><a href="https://i.stack.imgur.com/FVTAx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FVTAx.png" alt="pg_hba.conf" /></a></p>