'MongoDB error network is unreachable' can occur due to many reasons that include network issues, if the mongo server is not started, etc.
Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to fix MongoDB errors.
In this context, we shall look into ways to resolve this MongoDB error message.
How to fix 'MongoDB error network is unreachable' ?
Here, you will learn some tips to resolve this error message.
One of our customers was using Robo 3T on Mac and came across this error message.
This is how we resolved this error message.
1. First, we tried to ping the mongo server to see whether we can get responses. If we get responses then there is something wrong set with the mongo config.
However, if we don't get responses then it means there is something wrong with the network.
Here, we were not getting any responses so we checked the DNS and the network gateway. For instance, if the DNS is 172.16.* and the network gateway (execute ifconig and check en0) is 172.17.*.
Also, if they don’t belong to the same network segment.
Thus, here the DNS cannot interpret the mongo host correctly. Someone may have polluted this DNS server.
So, to fix this issue we manually set DNS for the devices.
2. Another fix is, we access the bin folder present in the path C:\Program Files\MongoDB\Server\4.2\bin
Then, we open the command prompt at this location and run the below command and then try to connect with Robo 3T:
Also, we can create a data folder inside your C: drive & then create a DB named folder inside the data folder.
3. If the mongo server is not started then this error could occur. So restarting the database from the terminal can also fix this issue.
For that, we can run the below command: