I am getting error SequelizeConnectionError: connect ETIMEDOUT
when trying to connect to a remote mysql db with sequelize.
Connection can be established successfully when I try to connect to my local mysql db.
I'm using sequelize's default db connection code new Sequelize(...)
contained within models/index.js, with the following config (filled up with the correct values):
"production": {
"username": "root",
"password": null,
"database": "database_production",
"host": "127.0.0.1",
"dialect": "mysql"
}
I tried connecting to the remote db with a simple php script and it worked (so we can rule out issues on the remote db server side)
Any ideas?
For me, I have to:
1) Define exact information of my database at the local server (Xamp/ Mamp). It means I must have the existing database to connect, user name and password is a privileged account in your database.
2) Xamp/ Mamp must be online (of course). Default ports will be taken by this local server, so try a different port for mysql 8889
instead of 3306
.
And this is what I tried:
sequelize = new Sequelize('wohui', 'root', 'root', {
dialect: 'mysql',
host: 'localhost',
port: 8889
});
sequelize
.authenticate()
.then(() => {
console.log('Connection has been established successfully.');
})
.catch((err) => {
console.log('Unable to connect to the database:', err);
});
This error usually appears when the connection to the sql server is not established. Some things to take care of are :
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