How do I fix the timeout error on the connection between Node app and Mysql?

I am new to deployment. I have created a node droplet which I access successfully with Putty and also a database cluster, which in the mysql workbench works fine, also when I connect it with the code in development so locally works just fine. The problem is that when I access the droplet, clone the project, after npm install and npm start to test it shows me timeout error from the database:

Error: connect ETIMEDOUT
    at Connection._handleTimeoutError (/root/gmd-server/node_modules/mysql2/lib/connection.js:178:17)
    at ontimeout (timers.js:482:11)
    at tryOnTimeout (timers.js:317:5)
    at Timer.listOnTimeout (timers.js:277:5)

I hope I was clear. How can I fix it? Thanks in advance.

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.

Hi there @majkellveizaj,

This sounds like a firewall problem, I could suggest a few things:

  • If you have added trusted sources for your cluster, make sure to allow your Droplet’s IP address as well

  • If you are using a firewall on your Droplet like UFW for example, make sure to open the Managed Database port for outgoing TCP connections from your Droplet

Let me know how it goes! Regards, Bobby