By Matthias
Hi there,
I created a managed mongodb to which I want to connect over my VPN which runs on another droplet in the same VPC. I use this VPN to connect from outside to other resources in the VPC. However, when I want to connect to the managed mongodb, that doesn’t work. I thought connection works when I add the IP range of the VPC to the trusted sources of the managed mongodb, and then use the ‘VPC network’ private hostname of the mongobd in the connection string, but that won’t work. Connection is only established when I add my computer’s IP address to the trusted sources but that’s a thing I would like to avoid.
Any hints?
Greetings Matthias
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!
Accepted Answer
Hi there Matthias,
I believe that you would need to configure your VPN Droplet’s IP addresses to your MongoDB trusted sources.
You should be able to do this by:
Ensure that your VPN Droplet and the managed MongoDB instance are in the same VPC and the VPN is properly configured to allow traffic between your local computer and the VPC resources.
Add the VPN Droplet’s private IP address (the one in the VPC) to the trusted sources of the managed MongoDB instance. You can do this from the DigitalOcean Control Panel under the “Databases” tab, by clicking on your managed MongoDB instance and navigating to the “Settings” tab. Under “Trusted Sources,” click “Add Source” and enter the private IP address of your VPN droplet.
Configure your VPN to forward traffic to the managed MongoDB instance. This may involve adding routing rules or configuring NAT on your VPN droplet, depending on your VPN setup. Here is a link to the documentation on how to setup that:
https://docs.digitalocean.com/products/networking/vpc/how-to/configure-droplet-as-gateway/
Let me know how it goes!
Best,
Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
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
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.