title: NestJS and TypeORM fail to connect my local Postgres database. Claims my database does not exist, even tho it does
body: <p>I have NestJS application that uses TypeORM to connect to my local database. I create database with shell script:</p>
  
  <pre><code>#!/bin/bash
  set -e
  
  SERVER="my_database_server";
  PW="mysecretpassword";
  DB="my_database";
  
  echo "echo stop &amp; remove old docker [$SERVER] and starting new fresh instance of [$SERVER]"
  (docker kill $SERVER || :) &amp;&amp; \
    (docker rm $SERVER || :) &amp;&amp; \
    docker run --name $SERVER -e POSTGRES_PASSWORD=$PW \
    -e PGPASSWORD=$PW \
    -p 5432:5432 \
    -d postgres
  
  # wait for pg to start
  echo "sleep wait for pg-server [$SERVER] to start";
  SLEEP 3;
  
  # create the db 
  echo "CREATE DATABASE $DB ENCODING 'UTF-8';" | docker exec -i $SERVER psql -U postgres
  echo "\l" | docker exec -i $SERVER psql -U postgres
  </code></pre>
  
  <p>After that, it logs databases:
  <a href="https://i.stack.imgur.com/wZbxq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wZbxq.png" alt="enter image description here"></a></p>
  
  <p>Then I fire up my application, and I encounter error "error: database "my_database" does not exist"</p>
  
  <p>I use following code to connect to database: </p>
  
  <pre><code>static getDatabaseConnection(): TypeOrmModuleOptions {
          console.log(require('dotenv').config())
          return {
              type: 'postgres',
              host: "127.0.0.1",
              port: 5432,
              username: 'postgres',
              password: 'mysecretpassword',
              database: 'my_database',
              entities: ['dist/**/*.entity{.ts,.js}'],
              synchronize: true,
          };
      }
  </code></pre>
  
  <p>Any ideas where do I go wrong? </p>