Report this

What is the reason for this report?

Nodejs connecting to managed mysql database ERR: connect ETIMEDOUT

Posted on July 11, 2020

Hi, my nodejs has connect ETIMEDOUT error. i wonder what is happening.

this is my connection on my nodejs var mysql = require(‘mysql’);

var con = mysql.createConnection({ host: “db-mysql-xxx-xxx-do-user-xxx-0.a.db.ondigitalocean.com”, user: “xxx”, password: ‘xxx’, database: “xxx”, multipleStatements:true, port: 8889, queryTimeout: 6000, connectTimeout: 60000, });

con.connect(function (err){ if(err) throw err; });

module.exports = con;



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there @legihendra7,

I think that the 8889 port that you are using is not correct. You can verify this via your DigitalOcean control panel then go to Databases -> and then click on manage for your database.

Also, if you have a firewall on your Droplet, make sure that the port is open for outgoing TCP connections.

Let me know how it goes! Regards, Bobby

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.