title: NestJS [TypeOrmModule] Unable to connect to the database
body: <p>I want to connect to a remote PostgreSQL database (which is being hosted on Heroku) and getting this error:</p>
  <pre><code>error: no pg_hba.conf entry for host &quot;&lt;My public IP address&gt;&quot;, user &quot;&lt;username&gt;&quot;, database &quot;&lt;dbname&gt;&quot;, SSL off
  </code></pre>
  <p>Here's my <code>app.module.ts</code></p>
  <pre><code>import { Module } from '@nestjs/common';
  import { TypeOrmModule, TypeOrmModuleOptions } from '@nestjs/typeorm';
  
  const cfg: TypeOrmModuleOptions = {
    type: 'postgres',
    host: process.env.DB_HOST,
    database: process.env.DB_NAME,
    username: process.env.DB_USER,
    password: process.env.DB_PASSWORD,
    port: Number(process.env.DB_PORT),
  };
  
  @Module({
    imports: [TypeOrmModule.forRoot(cfg)],
  })
  export class AppModule {}
  </code></pre>
  <p>Every <code>DB_*</code> variable matches corresponding values in Heroku's <code>Database Credentials</code></p>
  <p>I think that the problem is somewhere in <code>TypeORM</code>, because connecting to the same DB with the same <code>.env</code> file values worked in my other application (written in different programming language)</p>
  <p>Any ideas on what could be wrong?</p>