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

Become a contributor for community

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

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

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.