Unable to setup remote access for mongodb

For some days now I have been trying to setup remote access for mongodb server which i am running in our 64gb ram azure machine. I tried using docker, docker-compose and using nginx as reverse proxy for mongodb, but this didnt work. Basically i found out that :

  • I am unable to bind the host (server-public-ip-address) to the nginx proxy running.

So I switched over to not using docker instead running them as services and still configuring nginx as reverse proxy, I still noticed that while I was able to see the nginx default home page when i access the server public ip address (or dns which i have set up in azure) but I am still not able to connect to my mongodb using compass or mongosh using the public ip address which nginx is running on.

Now, I am no longer using nginx and I am still not able to configure remote access to mongodb by adding the access anywhere ipaddress in the bindIp parameter. Also i have added a rule in the firewall to allow any ip address to access the port 27017 for mongodb. So i dont know what really is happening with mongodb, Isnt it possible to access mongodb remotely ?

It works. There’s something wrong in your setup. Here’s all it takes in the mongod.conf :

  port: 27017

You were right as a debugging step to eliminate any proxying.
It’s almost certainly something wrong with your Azure setup.
I recommend you set up MongoDB on a local machine and play with it and see how easy it is to set up for remote access, and then tackle your Azure setup.

@Jack_Woehr Hello Sir, Thanks for your help. I actually solved the issue, and yes it was something with azure. I had to open the 27017 from my azure network board for that vm.

1 Like