Setup MongoDB on Windows Server 2008
In the mongod.cfg (at C:\Program Files\MongoDB\Server\4.0\bin), just update:
# network interfaces
net:
port: 27017
# bindIp: 127.0.0.1
bindIp: 0.0.0.0
let the mongo db bing to 0.0.0.0 i.e. all interfaces and not only 127.0.0.1. Then it will allow connections to all interfaces.
I think I found how to achieve it. First of all, allow the port 27017 on your firewall. Then I installed Mongo as a service using a configuration file. I created the mongos.conf like this:
dbpath = d:\mongo\data
logpath = d:\mongo\logs
noauth = true # use 'true' for options that don't take an argument
I saved it under: d:\mongo\mongos.conf
Then I did this in the command line:
mongod --config d:\mongo\mongos.conf --reinstall
The key is to make sure there is no bind_ip config key in your configuration file. So it will allow mongo to be binded to any ip. You should then be able to go to
http://localhost:27017 and see the following message:
You are trying to access MongoDB on the native driver port. For http diagnostic access, add 1000 to the port number
And you should also be able to go to:
http://192.168.x.x:27017 (your ip) and you should see the same output.
Try running this command from an admin DOS prompt to open external access to the default MongoDB port 27017:
C:\> netsh.exe advfirewall firewall add rule name="MongoDB (port 27017)"
dir=in action=allow protocol=TCP localport=27017