How do I diagnose connection problems with MongoDB
-
03-10-2019 - |
Question
Using the c# driver and MongoDB on windows server. Connection code looks like this:
using (var mongo = new Mongo(ConnectionString))
{
mongo.Connect();
//do stuff
mongo.Disconnect();
}
if ConnectionString == "mongodb://LocalHost/MyCollection"
everything is fine if ConnectionString == anything else... doesn't work... even if I use my local IP
IE:
mongodb://192.168.0.55/MyCollection
Fails with the error:
"No connection could be made because the target machine actively refused it 192.168.0.55:27017"
Mongo IS running, I can connect on the other machine locally..
I'm at a loss for how to diagnose/fix this issue, any suggestions?
Solution
Is Windows Firewall blocking access?
OTHER TIPS
You must add a rule with the specified port (27017 is the default) in the Windows Firewall and surely will works.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow