Ahsan Shiekh
Ahsan Shiekh

Reputation: 11

why ssl is giving an error on heroku logs

I have deployed my server using heroku and now I created a database on heroku and connected it to my project successfully I am using 'knex' library to send/receive data from database I read the documentations on heroku and according to them my node server should have the following code to connect to database

var db = require('knex')({
client: 'pg',
connection: {
connectionString: process.env.DATABASE_URL,
ssl: true,
}
});

now the issue is that my server doesn't seem to have access to the database and when I check the heroku logs it says

UnhandledPromiseRejectionWarning: Error: self signed certificate
2020-05-02T13:14:15.550866+00:00 app[web.1]: at TLSSocket.onConnectSecure (_tls_wrap.js:1474:34)
2020-05-02T13:14:15.550887+00:00 app[web.1]: at TLSSocket.emit (events.js:310:20)
2020-05-02T13:14:15.550887+00:00 app[web.1]: at TLSSocket._finishInit (_tls_wrap.js:917:8)
2020-05-02T13:14:15.550888+00:00 app[web.1]: at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:687:12)

I don't know how to fix this and I am unable to find a solution on internet

Upvotes: 1

Views: 860

Answers (1)

Humphrey Luchetu
Humphrey Luchetu

Reputation: 11

https://devcenter.heroku.com/articles/heroku-postgresql#connecting-in-node-js change from ssl : true to ssl: { rejectUnauthorized: false }

Upvotes: 1

Related Questions