Servers running Debian7.7, Mongodb, Nmap6.0 - Thanks for your time.

I've user who can't connect to mongodb from his Win7 desktop. He has mongodb installed on it and he's trying to connect from the CML. There's no firewall between the two. But they are on different VLANs. The user can connect to the server using SSH.

I thought that if a port is in the listen state, it's open and could accept a connection from a client. Is that not the case?

C:\MongoDB-2.6.6\bin>mongo xxx.xx.xx.xxx -u username -p passwd
MongoDB shell version: 2.6.6
connecting to: xxx.xx.xx.xxx/test
2015-01-28T12:58:05.746-0600 warning: Failed to connect to xxx.xx.xx.xxx:27017,
reason: errno:10061 No connection could be made because the target machine actively refused it.
2015-01-28T12:58:05.747-0600 Error: couldn't connect to server xxx.xx.xx.xxx:27017 (xxx.xx.xx.xxx), 
connection attempt failed at src/mongo/shell/mongo.js:148
exception: connect failed
root@xxxxx:/# lsof -i :27017
mongod  5128 mongodb    8u  IPv4   9393      0t0  TCP localhost:27017 (LISTEN)

root@xxxxx:/# nmap -p 27017 xxx.xx.xx.xxx

Starting Nmap 6.00 ( http://nmap.org ) at 2015-01-29 11:20 CST
Nmap scan report for xxxxxx.xxxxxx.xxx (xxx.xx.xx.xxx)
Host is up (0.000031s latency).
27017/tcp closed unknown

Nmap done: 1 IP address (1 host up) scanned in 0.04 seconds
  • Doesn't seem like much troubleshooting has been done... Can you connect to mongodb if you log directly into the server where it's installed? What about clients on same VLAN? – jlehtinen Jan 29 '15 at 19:19
  • My bad, I should have mentioned that after connecting via ssh they could connect to mongodb. – mojo.average Jan 29 '15 at 20:11

The service is listening on the loopback adapter only. If you use the -n option to lsof (or netstat or ss), you'll see that the listening address is This means that connections made to your network IP address will not reach the listening process.

It looks like you need to set the net.bindIp configuration option.

  • Thanks, I commented out this line in /etc/mongod.conf and that was the fix. # Listen to local interface only. Comment out to listen on all interfaces. # bind_ip = – mojo.average Jan 29 '15 at 20:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.