Unable to connect to mongo on remote server
The issue was bindIp
didn't change. There was some issue in restarting mongo from my side.
The habit should be to verify if the bindIp actually changed or not. (using sudo netstat -tulpn | grep 27017
)
With mongoDB server version 3.6.4, Ubuntu 16.4.4 I solved this by setting the net section in /etc/mongod.conf like this:
net:
port: 27017
bindIpAll: true
# bindIp: 127.0.0.1
make sure that mongodb daemon is running, and listening on 0.0.0.0, but not 127.0.0.1 port
for example, for my local mongodb, it has this config:
[vodolaz095@steel ~]$ cat /etc/mongod.conf
##
### Basic Defaults
##
# Comma separated list of ip addresses to listen on (all local ips by default)
bind_ip = 127.0.0.1
# Specify port number (27017 by default)
#port = 27017
for mongodb server to listen for remote connections, you can change
# Comma separated list of ip addresses to listen on (all local ips by default)
bind_ip = 0.0.0.0
I have tried a different way to solve this issue. I have changed the config file from
bind_ip = 127.0.0.1
#port = 27017
to
bind_ip = 0.0.0.0
#port = 27017
Hope it helps. Happy coding ;)