title: Unable to connect nodejs app to Postrgres database on heroku using typeorm
body: <p>I am using typeorm to connect to Postgres database on my nodejs application. I am able to connect successfully on my local but upon deploying to heroku I have these errors based on my database configurations.</p>
  <pre class="lang-js prettyprint-override"><code>import { createConnection } from 'typeorm';
  ...
  
  export const databaseConnection = async (databaseURL:string) =&gt; {
      try {
          await createConnection({
              type: &quot;postgres&quot;,
              url: databaseURL,
              entities: [User],
              synchronize: true,
              ssl:  false
          });
          
  
      } catch (error) {
      }
  };
  
  databaseConnection(&quot;&lt;DATABASE_URL_FROM_HEROKU&gt;&quot;)
  </code></pre>
  
  <p>When I do this, I get the error <code>no pg_hba.conf entry for host , userdatabase  SSL off at Parser.parseErrorMessage</code></p>
  <p>And when I use <code>ssl: true</code> in the connection I get the error: <code>Error: self signed certificate at TLSSocket.onConnectSecure heroku</code></p>
  <p>When I removed the ssl property completely, it still didn't work.</p>
  <p>Most of the solutions I came across were done using sequelize like this one <a href="https://stackoverflow.com/questions/25000183/node-js-postgresql-error-no-pg-hba-conf-entry-for-host">here</a>.  but I am using typeorm. I do I get rid of this error please.</p>