Here are my config options:

options: { config: "/etc/mongod.conf"
, net: { bindIp: "," }
, processManagement: { fork: true, pidFilePath: "/var/run/mongodb/mongod.pid" }
, storage: { dbPath: "/data" }
, systemLog: { destination: "file", logAppend: true, path: "/log/mongod.log" } 

First thing I do is check to see if any mongod is running using

ps aux | grep mongod

I see no results as expected (I've run sudo chkconfig mongod off to make sure the service doesn't start at boot).

When I run

sudo mongod service start

And check /log/mongod.log I see this

getaddrinfo("") failed: Name or service not known
ERROR: listen(): bind() failed errno:98 Address already in use for socket:

I then run this

netstat -an | grep :27017

And get no results. So then I check to see if a mongod is running using

ps aux | grep mongod

I get get no results.

When I remove my from the config file the service starts and I can connect to it.

Do I need to explicitly have that in my conf file to allow external connections to mongo? If so, what am I doing wrong?

Disclaimer: I'm very weak with Linux.

  • 1
    The first thing I would try is removing the space between the comma and the second IP. It does not appear to be gracefully handled by mongod. Sep 5, 2014 at 12:51
  • I would also run "netstat -an |grep 27017" rather than "netstat -an |grep :27017" to confirm whether the port is in use. Sep 5, 2014 at 12:54
  • @JamesWahlin I typically put : when searching for ports because if I'm searching for ssh and don't include the : then I'll get any instance of 22 included, like would be there - just a habit. Sep 5, 2014 at 12:59
  • @JamesWahlin I removed the space before the ip and it worked. The weird thing is that I can't start the service using sudo service mongod start anymore, I have to use sudo mongod --config /etc/mongod.conf Sep 5, 2014 at 13:01
  • 1
    The service script will start mongod under its own user. I would take a look at the data files and make sure none are owned by root, which would be the case if created when running mongod directly with sudo. If not the case take a look at the mongod log file which may provide clues. Sep 5, 2014 at 13:04

1 Answer 1


Remove the space between the comma and the second IP. It does not look like mongod is handling gracefully.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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