Fort Kickass > IT > Can’t Connect to Remote MongoDB
Can’t Connect to Remote MongoDB
Here’s a quick one for you this fine Sunday afternoon. If you have a brand new install of MongoDB on a remote server, and you’re trying to connect to it with MongoDB Compass but you keep getting the following error:
MongoDB not running on the provided host and port
Then the issue probably has to do with IP binding in the config file,
Around line 30, you will see the following:
# network interfaces
bindIp: 127.0.0.1 # Listen to local interface only, comment to listen on all interfaces.
Despite the instructions to comment out the
bindIp line, you must actually replace the localhost address with 0.0.0.0, instead.
Once that is done, restart (or start) MongoDB again and you should be good to go.
Hat-tip to Markus W Mahlberg in this StackOverflow thread.
Just two small points that may help other people experiencing this issue.
On a Windows 10 box, I needed to run Mongo-Compass to connect to remote systems.
On a windows box the configuration file is mongo.cfg and is per default set to the configuration mentioned above.
Furthermore, I can only recommend to check the firewall ports are open (i.e. 27017 if that is being used.)