DEV Community

Joshua Rodriguez
Joshua Rodriguez

Posted on • Updated on

"ConnectionError [SequelizeConnectionError]: no pg_hba.conf entry for host..." in Heroku Postgresql using Sequelize

The code I was using while I got this error was:

sequelize = new Sequelize(process.env.DATABASE_URL);
Enter fullscreen mode Exit fullscreen mode

Now, Heroku requires SSL to be enabled according to this quote from Heroku's Help Site

The authentication failed because the connection didn't use SSL encryption: (SSL off). All Heroku Postgres production databases require using SSL connections to ensure that communications between applications and the database remain secure. If your client is not using SSL to connect to your database, you would see these errors even if you're using the right credentials to connect to it.

My code changed accordingly to solve the error and now looks like this:

    sequelize = new Sequelize(process.env.DATABASE_URL, {
      dialectOptions: {
        ssl: {
          require: true,
          rejectUnauthorized: false,
        },
      },
    });
Enter fullscreen mode Exit fullscreen mode

Top comments (0)