If we'll set the host
setting to localhost
as below
import type { PostgresConnectionOptions } from "typeorm/driver/postgres/PostgresConnectionOptions";
export default function generateTypeORM_Configuration(): PostgresConnectionOptions {
return {
type: "postgres",
host: "localhost",
port: 5432,
username: "postgres",
password: "pass1234",
entities: []
};
}
we could deal with
Error: connect ECONNREFUSED 127.0.01:5432
because of the loopback adapter. This problem has been discussed in ECONNREFUSED for Postgres on nodeJS with dockers topics.
However if to replace the localhost
with Docker service name:
{
type: "postgres",
host: "Database",
port: 5432,
username: "postgres",
password: "pass1234",
entities: [ MemberModel ]
}
version: "3.5"
services:
Database:
image: postgres
container_name: Example-Local-Database
ports:
- "${DATABASE_PORT}:${DATABASE_PORT}"
environment:
- "POSTGRES_PASSWORD=${DATABASE_PASSWORD}"
volumes:
- DatabaseData:/var/lib/postgresql/data
# ...
volumes:
DatabaseData:
name: Example-Local-DatabaseData
driver: local
we'll face with
getaddrinfo ENOTFOUND Database
error if try to run the migration. In the topics "getaddrinfo ENOTFOUND Database" when try to connect with Database from TypeORM CLI while basically connection is fine I have been told to set host
to localhost
- back to square one. Of course I have tried to comment about it in this topics before create new question.