I can connect locally, and I can connect when I change just the DATABASE_URL to another database that is hosted on Heroku, but I can't get a specific azure-hosted database to work, it always results in a timeout error:
Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
db.js
const dbnexus = new Sequelize(process.env.DATABASE_URL, {
dialect: 'postgres',
logging: true,
operatorsAliases: Sequelize.Op.Aliases,
dialectOptions: {
ssl: {
require: true,
rejectUnauthorized: false,
},
},
});
app.js
dbnexus
.authenticate()
.then(() => dbnexus.sync())
.then(() =>
app.listen(process.env.PORT || 3000, (res) => {
console.log(`[server]: App is listening on ${process.env.PORT}`);
})
)
.catch((e) => {
console.log('[server]: Server Crashed');
console.log(e);
});
My Heroku environment:
DATABASE_URL = [matches local environment DATABASE_URL connection string]
PGSSLMODE = require
SSLMODE = require
All the other questions about this error were issues with how the port was being set, but I am doing it the way they all suggest, and it works with a different database, so I don't think that's actually the issue.
CodePudding user response:
I found the issue. Heroku doesn't use static IPs, so the server wasn't allowing it through. I don't know why this produced a time-out error instead of something more informative. I ended up using a proxy (QuotaGuard with qgtunnel is the only thing I could get to work with Sequelize and Postgres) and then whitelist the static IP's that created.