npmpostgresql95% confidence\u2191 34

cannot connect an SSL secured database to typeorm

Full error message
This is my first time using NestJS and I am having trouble connecting my Postgres database which is hosted on Digitalocean to NestJS.

I searched online for solutions and tried adding "ssl": "true" or "extra": { "ssl": "true" }

Heres my ormconfig.json

{
  "type": "postgres",
  "host": "host",
  "port": "port",
  "username": "username",
  "password": "password",
  "database": "database",
  "extra": {
    "ssl": "true"
  },
  "synchronize": "true",
  "logging": "true",
  "entities": ["src/**/*.entity.ts", "dist/**/*.entity.js"]
}

I expect it to connect to the server. The error I'm getting is [TypeOrmModule] Unable to connect to the database. error: no pg_hba.conf entry for host "", user "", database "", SSL off

If anyone has the same issue, I fixed it by adding a field for ssl and setting my ca certificate that I got from Digital Ocean. Heres what my ormconfig looks like: module.exports = { name: 'default', type: 'postgres', host: 'host', port: port, username: 'username', password: 'password', database: 'database', synchronize: true, dropSchema: false, logging: true, ssl: { ca: process.env.SSL_CERT, }, entities: ['src/**/*.entity.ts', 'dist/**/*.entity.js'], };

API access

Get this solution programmatically \u2014 free, no authentication.

curl https://depscope.dev/api/error/c1e32948d1343a98137870887cbb5893cc889d974fff26d5742ff4f8cf6c1c8a
hash \u00b7 c1e32948d1343a98137870887cbb5893cc889d974fff26d5742ff4f8cf6c1c8a
cannot connect an SSL secured database to typeorm — DepScope fix | DepScope