3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

herokuデプロイ後sequelizeでPostgreSQLに接続できないときの解決法

Last updated at Posted at 2021-01-08

sequelizeを使ってPostgreSQLと接続したい。

ローカル環境では接続に成功していたが、herokuにデプロイした後は失敗する。

失敗

const Sequelize = require('sequelize');

// herokuまたはローカル環境のPostgreSQLに接続する
const sequelize = new Sequelize(process.env.DATABASE_URL || 'postgres://postgres:postgres@localhost/hogehoge');

成功

const Sequelize = require('sequelize');

const sequelize = new Sequelize(
  process.env.DATABASE_URL || 'postgres://postgres:postgres@localhost/hogehoge', 
  {dialectOptions: { ssl: true }}
);

ログを見るとssl off(うろ覚え)とあったので、このようにオプションを追加してみると接続に成功した。

3
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?