{"id":511,"hash":"c1e32948d1343a98137870887cbb5893cc889d974fff26d5742ff4f8cf6c1c8a","pattern":"cannot connect an SSL secured database to typeorm","full_message":"This is my first time using NestJS and I am having trouble connecting my Postgres database which is hosted on Digitalocean to NestJS.\n\nI searched online for solutions and tried adding \"ssl\": \"true\" or \"extra\": { \"ssl\": \"true\" }\n\nHeres my ormconfig.json\n\n{\n  \"type\": \"postgres\",\n  \"host\": \"host\",\n  \"port\": \"port\",\n  \"username\": \"username\",\n  \"password\": \"password\",\n  \"database\": \"database\",\n  \"extra\": {\n    \"ssl\": \"true\"\n  },\n  \"synchronize\": \"true\",\n  \"logging\": \"true\",\n  \"entities\": [\"src/**/*.entity.ts\", \"dist/**/*.entity.js\"]\n}\n\nI 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","ecosystem":"npm","package_name":"postgresql","package_version":null,"solution":"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. \nHeres what my ormconfig looks like:\n\nmodule.exports = {\n  name: 'default',\n  type: 'postgres',\n  host: 'host',\n  port: port,\n  username: 'username',\n  password: 'password',\n  database: 'database',\n  synchronize: true,\n  dropSchema: false,\n  logging: true,\n  ssl: {\n    ca: process.env.SSL_CERT,\n  },\n  entities: ['src/**/*.entity.ts', 'dist/**/*.entity.js'],\n};","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/56660312/cannot-connect-an-ssl-secured-database-to-typeorm","votes":34,"created_at":"2026-04-19T04:51:16.278138+00:00","updated_at":"2026-04-19T04:51:16.278138+00:00"}