Accessing Database (MongoDB / MySQL) using a VPN

I have a MongoDB instance I’ve setup, and under Trusted Sources, all works great. You can add an IP to connect, which may be your local machine, or the web server you’re using.

Since we’re in development, and don’t have a deployed application, we tend to simply add our IP address to the trusted source so our local application connects.

The Problem is however when we’re running a VPN on our local machine, and checking the current ip… it has one address… but then within DigitalOcean, (adding an IP to trusted source) it has a completely different IP. It will say ‘your computers IP’.

Is there a way to get this to work, or is it impossible via a VPN to add an IP to a trusted source that would connect?

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
November 3, 2022

Hi there,

It would really depend on how your VPN is configured, for example, your VPN might be filtering only some websites and not all of the traffic would be going over the VPN.

What I could suggest is getting in touch with your VPN provider and asking them for the IP range that you get assigned, and then using that IP range in your trusted sources list.

Let me know how it goes!



Try DigitalOcean for free

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

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

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

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
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
Get started for free

Enter your email to get $200 in credit for your first 60 days with DigitalOcean.

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

© 2023 DigitalOcean, LLC.