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 was able to solve my issues here. Essentially, I solved it by setting up the following correctly within the environment.:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With