I am a newbie for setting up the server environment and mongoDB. This may sounds something really simple, however, I really need your help on it.
I am trying to conn
Amazon-linux2 | Cent OS | MongoDB shell version: 3.0.15
This is how it needs to be done in the latest config
#network interfaces
net:
port: 27017
bindIp: [xxx.xxx.xxx.xxx,127.0.0.1] # Listen to local interface only, comment to listen on all interfaces.
Cheers!!
With MongoDB server version: 3.6.8 plain comma separated list worked for me. With or without spaces after comma.
bind_ip = 127.0.0.1, 192.168.0.104
bind_ip = 127.0.0.1,192.168.0.104
However, adding enclosing in []
fails with following error in MongoDB log
bind_ip = [127.0.0.1,192.168.0.104]
getaddrinfo("[127.0.0.1") failed: Name or service not known
bind_ip = [127.0.0.1, 192.168.0.104]
getaddrinfo("[127.0.0.1") failed: Name or service not known
You can do that by:
bindIp: [172.31.60.184,127.0.0.1]
Remember to not put a space after the comma.
The case in mongodb version 3.6 on my Ubuntu16.04 LTS is that you do not need to put the IP addresses in the square brackets "[]". Delete the space after the comma solve the failed connection problem in the mongod log (/var/log/mongodb/mongod.log)
NETWORK [initandlisten] getaddrinfo(" xxx.xxx.xxx.xxx") failed: Name or service not known
After modify the bindIp: 127.0.0.1
to bindIp: 127.0.0.1,xxx.xxx.xxx.xxx
(notice no comma between IPs), the host IP is listening as below:
xxx@xxxx:/var/log/mongodb$ sudo netstat -plnt |egrep mongod
tcp 0 0 xxx.xxx.xxx.xxx:27017 0.0.0.0:* LISTEN 30747/mongod
tcp 0 0 127.0.0.1:27017 0.0.0.0:* LISTEN 30747/mongod