Question

How to connect Function to managed Database?

I have a Function (nodejs) that is independent from the App Platform and I’m trying to connect to a managed database (mysql). The error I am getting is: “Database query failed: Error: connect ETIMEDOUT”.

I have successfully tested the function code locally, verified many times that the connection params for local and my function are exactly the same, removed trusted sources so that my database is open to the public…not sure what else I can do.

I have googled extensively and looked around DO community support and have come up with nothing aside from one or two related questions, one of which says you can’t connect to a managed database from a function that is independent from app platform, and another that was able to somehow add the IP of their function to the trusted sources of their managed database.

Is what I’m trying to do impossible?

Show comments

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.

Swarn Suvarna
DigitalOcean Employee
DigitalOcean Employee badge
May 8, 2023

Hello there,

Standalone function should be able to connect to Manged database. However it does not work if trusted source are enabled. From your question, I see that you have disabled trusted sources and it still does not work. We can check internally and see if there is any problem since trusted source was enabled earlier. Could you please create ticket in your DO account at https://cloud.digitalocean.com/account/support?

Thank you, Swarn suvarna.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel