HOW can i solve the Error: connect ETIMEDOUT when try to connect node with DO Mysql database

const MYSQL_CONF = {
    host: '',
    username: 'doadmin',
    password: 'xxxxxxxx',
    database: 'defaultdb',
    // port: 25060,
    dialect: 'mysql',
    dialectOptions: {
        ssl: {
            ssl: true,
            cert: fs.readFileSync(path.resolve(__dirname, 'ca-certificate.crt')).toString('utf8')

const con = mysql.createConnection(MYSQL_CONF)
con.connect((err, result) => {
    if (err) {
        throw new Error(err)

The configuration is coded above, and i am not sure if this is the correct one…The error always states the Error: connect ETIMEDOUT…

the funny thing is that i can connect the cluster with mysql client terminal and workbench on my local machine, but it doesn’t work with node.js…

Could someone help me out, many thanks?

Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

@zhangboyu did you ever figure this out? I’m having the same exact issue I can connect with workbench but not with node mysql

Hi @zhangboyu, I have the same issue, During my development stage I established many connection pools to the database, after some time database firewall blocks my request, so set up a VPN and tried again and it will work. Solution: Try some VPN

Hi there @zhangboyu,

I can see that the custom port is commented out, you need to have that port specifically defined in your connection string.

Another thing that I would recommend trying to create a new user with MySQL native password and try using it instead of the default user. You can do that via your DigitalOcean control panel.

Also if your Node.js app is running on a Droplet, I would recommend checking if port 25060 is open for outgoing TCP connections, to test that you can use the following telnet command:

  1. telnet 25060

Let me know how it goes! Regards, Bobby