5

I am struggling with the database connection getting error:

Unable to connect to the database: ConnectionError [SequelizeConnectionError]: self signed certificate

Here you have the code which I use - the part which is commented does not work, the error still appears:


// const pg = require('pg');
// pg.defaults.ssl = true;

// const fs = require('fs');
// const rdsCa = fs.readFileSync(__dirname + '/rds-combined-ca-bundle.pem');


const sequelize = new Sequelize('xxxx', 'xxxxxx', 'xxxxxxxx',{
    host: 'xxxxxx.eu-west-1.compute.amazonaws.com',
    dialect: 'postgres',
    ssl: true,
    protocol: "postgres",

    logging: true,
        dialectOptions: {
        ssl: true
    }
});
sequelize
    .authenticate()
    .then(() => {
        console.log('Connection has been established successfully.');
    })
    .catch(err => {
        console.error('Unable to connect to the database:', err);
    });

The database is built on Heroku.

Can you please help me how to solve the issue?

syeenn
  • 191
  • 2
  • 3
  • 11
  • Does this answer your question? [SequelizeConnectionError: self signed certificate](https://stackoverflow.com/questions/58965011/sequelizeconnectionerror-self-signed-certificate) – CherryDT Aug 05 '20 at 20:03

0 Answers0