marvin ralph
marvin ralph

Reputation: 1280

How To Connect Sequelize Node To Amazon RDS Postgres

I'm having trouble connecting sequelize to Amazon RDS Postgres DB.

Below is my connection String:

const dbConfig = new Sequelize(database, username, password, {
  host: host,
  ssl: true,
  dialect: "postgres",
  logging: console.log,
});

This prints the ff error:

SequelizeConnectionError: password authentication failed for user "USER01"

This USER01 is my local postgres username. I don't even know why its trying to connect to my local server.

If I provide the ff connection string:

const dbConfig = new sequelize.Sequelize(database, username, password, {
  host: host,
  ssl: true,
  dialect: "postgres",
  dialectOptions: {
    ssl: "Amazon RDS"
  },
  logging: console.log,
});

I get the ff error:

C:\Users\USER01\Desktop\myproject\node_modules\pg\lib\connection.js:85
        if ('key' in self.ssl) {
                  ^

TypeError: Cannot use 'in' operator to search for 'key' in Amazon RDS
    at Socket.<anonymous> (C:\Users\USER01\Desktop\myproject\node_modules\pg\lib\connection.js:85:19)
    at Object.onceWrapper (events.js:422:26)
    at Socket.emit (events.js:315:20)
    at addChunk (_stream_readable.js:295:12)
    at readableAddChunk (_stream_readable.js:271:9)
    at Socket.Readable.push (_stream_readable.js:212:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:186:23)

NOTE: The connection strings I'm proving are my Amazon RDS connection details.

Upvotes: 0

Views: 1869

Answers (1)

Wang Liang
Wang Liang

Reputation: 4444

dialectOptions: {
    ssl: {
       {rejectUnauthorized: false},
    }
}

Please try with this

Upvotes: 1

Related Questions