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!
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.
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
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:
Let me know how it goes!
Best,
Bobby