Issue with bind_ip on mongodb mon Virtualbox

black sensei asked:

I have been struggling with mongo bind IP for a while , I think this is the time to shout for help. I am using hostonly network . I have 4 boxes. 3 boxes for mongo,, and one box for the app

So for mongo bind param is : bind_ip =,,,,,

2015-08-22T12:35:44.547+0000 E NETWORK  [initandlisten] listen(): bind() failed errno:99 Cannot assign requested address for socket:
2015-08-22T12:35:44.553+0000 I JOURNAL  [initandlisten] journal dir=/var/lib/mongodb/journal
2015-08-22T12:35:44.554+0000 I JOURNAL  [initandlisten] recover : no journal files present, no recovery needed
2015-08-22T12:35:44.623+0000 I JOURNAL  [durability] Durability thread started
2015-08-22T12:35:44.624+0000 I JOURNAL  [journal writer] Journal writer thread started
2015-08-22T12:35:44.624+0000 I CONTROL  [initandlisten] MongoDB starting : pid=3519 port=27017 dbpath=/var/lib/mongodb 64-bit host=vagrant-ubuntu-trusty-64
2015-08-22T12:35:44.625+0000 I CONTROL  [initandlisten] db version v3.0.5
2015-08-22T12:35:44.625+0000 I CONTROL  [initandlisten] git version: 8bc4ae20708dbb493cb09338d9e7be6698e4a3a3
2015-08-22T12:35:44.625+0000 I CONTROL  [initandlisten] build info: Linux ip-10-183-35-50 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
2015-08-22T12:35:44.625+0000 I CONTROL  [initandlisten] allocator: tcmalloc
2015-08-22T12:35:44.626+0000 I CONTROL  [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: ",,,,,", port: 27017 }, storage: { dbPath: "/var/lib/mongodb" }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2015-08-22T12:35:44.631+0000 I CONTROL  [initandlisten] now exiting
2015-08-22T12:35:44.631+0000 I NETWORK  [initandlisten] shutdown: going to close listening sockets...
2015-08-22T12:35:44.632+0000 I NETWORK  [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2015-08-22T12:35:44.632+0000 I NETWORK  [initandlisten] shutdown: going to flush diaglog...
2015-08-22T12:35:44.632+0000 I NETWORK  [initandlisten] shutdown: going to close sockets...
2015-08-22T12:35:44.632+0000 I STORAGE  [initandlisten] shutdown: waiting for fs preallocator...
2015-08-22T12:35:44.632+0000 I STORAGE  [initandlisten] shutdown: final commit...
2015-08-22T12:35:44.635+0000 I JOURNAL  [initandlisten] journalCleanup...
2015-08-22T12:35:44.635+0000 I JOURNAL  [initandlisten] removeJournalFiles
2015-08-22T12:35:44.636+0000 I JOURNAL  [initandlisten] Terminating durability thread ...
2015-08-22T12:35:44.735+0000 I JOURNAL  [journal writer] Journal writer thread stopped
2015-08-22T12:35:44.736+0000 I JOURNAL  [durability] Durability thread stopped
2015-08-22T12:35:44.736+0000 I STORAGE  [initandlisten] shutdown: closing all files...
2015-08-22T12:35:44.736+0000 I STORAGE  [initandlisten] closeAllFiles() finished
2015-08-22T12:35:44.737+0000 I STORAGE  [initandlisten] shutdown: removing fs lock...
2015-08-22T12:35:44.737+0000 I CONTROL  [initandlisten] dbexit:  rc: 48

I really don’t see what’s wrong anything with any other IP. aside loopback, own IP and every other IP fails to start mongodb.

My answer:

The bind_ip directive is meant to specify the IP addresses on that same system to which MongoDB listens for connections, not IP addresses from which it receives connections.

Set this option to configure the mongod or mongos process to bind to and listen for connections from applications on this address. You may attach mongod or mongos instances to any interface; however, if you attach the process to a publicly accessible interface, implement proper authentication or firewall restrictions to protect the integrity of your database.

So it should either be absent (recommended), or contain to accept only local connections, or the IP address of the local network interface.

If you want to restrict what IP addresses can connect to MongoDB, you’ll need to use the firewall.

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.