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.