Main Tutorials

MongoDB – bind() failed errno:99 Cannot assign requested address for socket

Review the server environment, we need to allow Server B to access the Server A MongoDB database.


Server A - MongoDB server
Private IP - 192.168.162.129 / 17

Server B - Application Server
Private IP - 192.168.204.205 / 17

Update the bind_ip, but unable to start mongod process anymore.

/etc/mongod.conf

#$ vim /etc/mongod.conf

# Listen to local interface only. Comment out to listen on all interfaces.
bind_ip = 127.0.0.1, 192.168.162.129, 192.168.204.205
/var/log/mongodb/mongod.log

E NETWORK  [initandlisten] listen(): bind() failed errno:99 Cannot assign requested address for socket: 192.168.204.205:27017
E STORAGE  [initandlisten] Failed to set up sockets during startup.

Solution

The bind_ip is for “local interface only”, put 192.168.162.129 (Server A private ip) is enough for clients (like Server B) on the same LAN to access.

/etc/mongod.conf

#$ vim /etc/mongod.conf

# Listen to local interface only. Comment out to listen on all interfaces.
bind_ip = 127.0.0.1, 192.168.162.129

References

  1. MongoDB – Allow remote access
  2. MongoDB – bind_ip documentation

About Author

author image
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

Subscribe
Notify of
2 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Nathan
6 years ago

mkyong,

This is incorrect as of MongoDB 3.6 release. It is bindIp, not bind_ip. Also, ensure there are no spaces between entries:

bindIp: 127.0.0.1,192.168.162.129

Satya Kanodia
6 years ago

Well explained