admin管理员组文章数量:1404927
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!
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!
Share Improve this question edited Mar 7, 2016 at 6:15 James asked Feb 23, 2016 at 6:30 JamesJames 1811 silver badge9 bronze badges2 Answers
Reset to default 4I 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 puter. By default, it seems RDS sets up the IP that you are using to be able to use it... which makes sense..)
I had a very similar problem, and it turned out I had a question mark in my password — causing half the password and the remainder of the connection URL to be ignored (as apparently part of the URL search portion).
Something like:
new Sequelize("postgres://fred:[email protected]/db");
Where we end up with username: fred, password: xj78, and everything else blank.
Escaping the question mark as %3F fixes the issue.
版权声明:本文标题:javascript - Issues connecting to Amazon RDS Postgres database on node.js using sequelize ORM - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744873756a2629791.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论