LoginSignup
3
2

More than 3 years have passed since last update.

HerokuのPostgreSQLにSSL接続する

Posted at

  
短いですが備忘録として残しておきます!

エラー

Node.jsのORM(Object Relation Mapping)であるSequelizeを利用して、
ローカルからHerokuのPostgreSQLに接続する際に下記のエラーが出て接続できませんでした。。

error: no pg_hba.conf entry for host "DB_HOST", user "DB_USER", database "DB", SSL off

これはSSL接続がオフになっているためオプションでオンにしてあげる必要があります。

解決

const Sequelize = require('sequelize')
const sequelize = new Sequelize(
  'postgres://~~', // DB情報
  {
    // DBにSSL接続する
    dialectOptions: {
      ssl: true,
    },
  }
)

上記のようにSSL接続をtrueとすることで解決しました!

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2