Cannot connect to mongodb using machine ip

I just tested this on my Mac with Homebrew, works fine if you change the bind address. I suspect you probably just didn’t get the config for bind correct?

Just so we have all the information, can you paste the output of ifconfig please?

By default, MongoDB should listen on all interfaces, you shouldn’t need to change the configuration, however, the Homebrew setup seems to override this (/usr/local/etc/mongod.conf):

# Only accept local connections
bind_ip = 127.0.0.1

Please kill MongoDB and run this (note the -v):

$ mongod --bind_ip 0.0.0.0 -v
warning: bind_ip of 0.0.0.0 is unnecessary; listens on all ips by default
all output going to: /usr/local/var/log/mongodb/mongo.log

Just paste your output for that please?

And then just try:

$ mongo --host 192.168.43.2 --verbose
MongoDB shell version: 2.4.6
Sat Aug 24 09:07:14.556 versionArrayTest passed
connecting to: 192.168.43.2:27017/test
Sat Aug 24 09:07:14.657 creating new connection to:192.168.43.2:27017
Sat Aug 24 09:07:14.657 BackgroundJob starting: ConnectBG
Sat Aug 24 09:07:14.657 connected connection!
Server has startup warnings: 
Sat Aug 24 09:06:44.360 [initandlisten] 
Sat Aug 24 09:06:44.360 [initandlisten] ** WARNING: soft rlimits too low. Number of files     is 256, should be at least 1000
> 

Obviously replace it with your IP address. Let us know how that goes.

Leave a Comment