tcp 0 0 localhost:27017 0.0.0.0:* LISTEN
@Jay Gordon blog documented here This output means that users are only permitted to access our MongoDB instance on port 27017 via IP 127.0.0.1.
mongos bind to
localhost by default. See Default Bind to Localhost.
The hostnames and/or IP addresses and/or full Unix domain socket paths on which mongos should listen for client connections. You may attach mongos to any interface. To bind to multiple addresses, enter a list of comma-separated values.
Note: When possible, use a logical DNS hostname instead of an ip address, particularly when configuring replica set members or sharded
cluster members. The use of logical DNS hostnames avoids configuration
changes due to ip address changes.
To bind to all IPv4 addresses, enter
To bind to all IPv4 and IPv6 addresses, enter
::,0.0.0.0 or alternatively, use the
Enable Access Control and Enforce Authentication
Enable access control and specify the authentication mechanism. You can use the default MongoDB authentication mechanism or an existing external framework. Authentication requires that all clients and servers provide valid credentials before they can connect to the system. In clustered deployments, enable authentication for each MongoDB server.
See Authentication and Enable Auth.
Before you bind to other ip addresses, consider enabling access control and other security measures listed in Security Checklist to prevent unauthorized access.
If you would like to make this available to other systems on your network, you'll want to bind the local IP associated with the private network. To determine network interface configuration easily, we can just run an ifconfig from the command line:
To determine network interface configuration easily, we can just run an ifconfig from the command line:
eth0 Link encap:Ethernet HWaddr 0e:5e:76:83:49:3e
inet addr:172.16.0.211 Bcast:172.16.0.255 Mask:255.255.255.0
inet6 addr: fe80::c5e:76ff:fe83:493e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:9001 Metric:1
RX packets:65521 errors:0 dropped:0 overruns:0 frame:0
TX packets:7358 errors:0 dropped:0 overruns:0 carrier:0
RX bytes:94354063 (94.3 MB) TX bytes:611646 (611.6 KB)
We have the IP we want to make part of the list of acceptable network addresses we can listen from. I will open the /etc/mongodb.conf file and edit it to reflect the additional network IP:
The file's changes will be:
# network interfaces
After modifying bindIP under "net" from just 127.0.0.1 to include private IP address 172.16.0.211, we should be able to restart and see it listening from netstat on both now:
ubuntu@ip-172-16-0-211:~$ sudo service mongod stop
ubuntu@ip-172-16-0-211:~$ sudo service mongod start
ubuntu@ip-172-16-0-211:~$ sudo netstat -plnt | egrep mongod
tcp 0 0 172.16.0.211:27017 0.0.0.0:* LISTEN 2892/mongod
tcp 0 0 127.0.0.1:27017 0.0.0.0:* LISTEN 2892/mongod
For further your ref here and here