Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
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 :
Ensure mysql server is running in the host you are trying to connect to.
Ensure the host ip is correct.
Ensure that the port entered is correct.
Ensure that the firewall rules are defined correctly.
Remote root access not granted by the mysql server.
The configs are filtered by the environment, Which ideally is done by using the NODE_ENV variable, can you try running your server locally with prod config. In my case, I would do something like NODE_ENV=production node server.js
. Assuming server.js
is the start file. You can try logging the value's before new Sequelize(...)
, that might give a better idea as to what's going in.
–
I had the same issue and my problem was in the ports. MySql had ports 3306 and in the config, i wrote port 3000 :D
Thanks for helped
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.