Issues connecting to Amazon RDS Postgres database on node.js using sequelize ORM
·
Answer a question
I'm currently working on migrating an environment set up in Heroku over to the Amazon Web Services stack (RDS PostgreSQL, Elastic Beanstalk).
I'm facing some issues when trying to connect to PostgreSQL through the sequelize.js ORM. Error message below:
Unhandled rejection SequelizeHostNotFoundError: getaddrinfo ENOTFOUND [host].
I can connect to the database through pgAdmin so I know the service is working, and the following configuration has worked on Heroku:
sequelize = new Sequelize(process.env.DATABASE_URI, {
dialect: 'postgres',
protocol: 'postgres',
logging: true,
timestamps: false
})
DATABASE_URI is formatted in the following way:
postgres://[db_username]:[db_password]@[hostname]:[port]/[db_name]
Any help would be greatly appreciated. Thanks in advance!
Answers
I was able to solve my issues here. Essentially, I solved it by setting up the following correctly within the environment.:
- Formatting URI correctly - (Following the syntax above, I was able to get it to work)
- Enabling security provisions for Amazon RDS & Elastic Beanstalk - I had to enable Inbound access to the Amazon RDS instance for the Security group / Instance Role that the Elastic Beanstalk was running under. (I got caught up in the fact that I was able to hit RDS through my local computer. By default, it seems RDS sets up the IP that you are using to be able to use it... which makes sense..)
更多推荐
所有评论(0)