title: heroku DATABASE_URL is undefined in nodejs app
body: <p>Heroku site states that the DATABASE_URL is setup automatically for you.  I used the command 
  <code>heroku config</code>
  to confirm that the DATABASE_URL is indeed set. </p>
  
  <p>However when I use the pg package command</p>
  
  <pre><code>const client = new Client({
      connectionString: process.env.DATABASE_URL,
      ssl: true,
  });
  </code></pre>
  
  <p>and do a <code>console.log(process.env.DATABASE_URL)</code>, the variable reads as <code>undefined</code>.</p>
  
  <p>The other errors that I am getting are:</p>
  
  <p><em>UnhandledPromiseRejectionWarning: Error: The server does not support SSL connections</em></p>
  
  <p>The complete code is:</p>
  
  <pre><code>const express = require('express');
  require('dotenv').config();
  
  const { Client } = require('pg');
  const app = express();
  
  console.log(process.env.DATABASE_URL);
  
  const client = new Client({
      connectionString: process.env.DATABASE_URL,
      ssl: true,
  });
  
   client.connect();
  
   client.query('SELECT * FROM customers;', (err, res) =&gt; {
      if (err) throw err;
      for (let row of res.rows) {
          console.log(JSON.stringify(row));
      }
      client.end();
  });
  
  
  app.get('/', (req, res) =&gt; { 
      res.send('Hello World')
  });
  
  
  app.listen(4000, () =&gt; {
      console.log(`Server started on port`);
  });
  </code></pre>
  
  <p>The code works when I use my local postgresql database, but when I try to connect to Heroku's postgres database, the above errors occur.  Any suggestions?</p>