Deploying Error in Nodejs project due to Database connection error

I had deployed a nodejs project on render which previously used postgres db from render only and that worked fine. but it is about to expire as its free and now i have created a free postgres db on aiven and connected it to my local pgadmin4 now while redeploying it with new db url it is giving me this error

Database connection error: Error: self-signed certificate in certificate chain

Nov 15 12:15:36 PM at TLSSocket.onConnectSecure (node:_tls_wrap:1679:34)

Nov 15 12:15:36 PM at TLSSocket.emit (node:events:518:28)

Nov 15 12:15:36 PM at TLSSocket._finishInit (node:_tls_wrap:1078:8)

Nov 15 12:15:36 PM at ssl.onhandshakedone (node:_tls_wrap:864:12) {

Nov 15 12:15:36 PM code: ‘SELF_SIGNED_CERT_IN_CHAIN’

Nov 15 12:15:36 PM}

Nov 15 12:15:36 PM/opt/render/project/src/node_modules/pg/lib/client.js:535

Nov 15 12:15:36 PM Error.captureStackTrace(err)

Nov 15 12:15:36 PM ^

Nov 15 12:15:36 PM

Nov 15 12:15:36 PMError: Connection terminated unexpectedly

Nov 15 12:15:36 PM at /opt/render/project/src/node_modules/pg/lib/client.js:535:17

Nov 15 12:15:36 PM at process.processTicksAndRejections (node:internal/process/task_queues:105:5)

Nov 15 12:15:36 PM at async checkVisisted (file:///opt/render/project/src/index.js:35:18)

Nov 15 12:15:36 PM at async file:///opt/render/project/src/index.js:50:21

Nov 15 12:15:36 PM

Nov 15 12:15:36 PMNode.js v22.10.0

Nov 15 12:15:38 PM==> Exited with status 1

Nov 15 12:15:38 PM==> Common ways to troubleshoot your deploy: Troubleshooting Your Deploy – Render Docs

Nov 15 12:15:43 PM==> Running ‘node index.js’

Nov 15 12:15:44 PMServer running on http://localhost:10000

Nov 15 12:15:44 PMDatabase connection error: Error: self-signed certificate in certificate chain

Nov 15 12:15:44 PM at TLSSocket.onConnectSecure (node:_tls_wrap:1679:34)

Nov 15 12:15:44 PM at TLSSocket.emit (node:events:518:28)

Nov 15 12:15:44 PM at TLSSocket._finishInit (node:_tls_wrap:1078:8)

Nov 15 12:15:44 PM at ssl.onhandshakedone (node:_tls_wrap:864:12) {

Nov 15 12:15:44 PM code: ‘SELF_SIGNED_CERT_IN_CHAIN’

Nov 15 12:15:44 PM}

in my db connections i have already mentioned
ssl: {
rejectUnauthorized: false,
},
also tried putting the CA certificate
ssl: {
ca: fs.readFileSync(‘ca.pem’).toString(),
rejectUnauthorized: true,
},

but still gives the same error, any help would be much appreciated.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.