Question

Calling a DB from a Function using the VPC hostname

Hello all. When I’m connecting from a serverless Function to a managed MySQL DB using the VPC network host name, the connection is refused:

"error":"connect ECONNREFUSED 10.108.0.2:25060"

My question: are we forced to use the public host name of the DB from a Function, or am I missing something? When I will link this Function to an App on the App Platform and have this App a trusted source of the DB - will that allow me to use the internal host name from the Function?

Thanks! Mor


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.

Bobby Iliev
Site Moderator
Site Moderator badge
March 12, 2024
Accepted Answer

Hey @morsagmonstarfish,

Indeed, this is not yet possible with the stand-alone functions. You would need to deploy them as part of an App or use the public Database endpoint.

It looks like someone has had the same idea before and has posted it on our Product Ideas board. The best thing to do would be to head over and add your vote to it, as well as adding any additional information in the comments for exactly what you’d like to see implemented!

https://ideas.digitalocean.com/network/p/allow-access-functions-to-vpc

Hope that helps!

- Bobby.

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