Mongodb – “ERROR: could not read from config file” MongoDB

mongodb

I'm trying to configure MongoDB in OS X Mountain Lion. I've installed with Homebrew; I have followed lots of tutorials, but I have got an issue which I haven't been able to solved.

The issue is about mongod.conf file. I've got it in /usr/local/Cellar/mongodb/2.4.6/ directory and it contains the following code:

fork = true
bind_ip = 127.0.0.1
port = 27017
quiet = true
dbpath = /usr/local/Cellar/mongodb/2.4.6/data/db
logpath = /usr/local/Cellar/mongodb/2.4.6/data/log/mongod.log
logappend = true
journal = true

Why if I execute mongod in the terminal appears a ERROR: could not read from config file?

Best Answer

First, assuming you are actually specifying where to read the file from, make sure that you have permission read that file with the current user (cat /usr/local/Cellar/mongodb/2.4.6/mongod.conf - or use less/vi/editor of choice). Assuming that works (and if it does not, adjust your permissions), then the next thing you need to do is make sure you are actually pointing at the correct file.

However, if you are not specifying where to read the file from, by default, if you just run mongod using the brew installation it will attempt to read from:

/usr/local/etc/mongod.conf

I verified this by installing 2.4.6 with brew and then checking the logs when it starts up:

Tue Oct 22 17:17:30.695 [initandlisten] options: { bind_ip: "127.0.0.1", config: "/usr/local/etc/mongod.conf", dbpath: "/usr/local/var/mongodb", logappend: "true", logpath: "/usr/local/var/log/mongodb/mongo.log" }

You can either modify that file (/usr/local/etc/mongod.conf) to look the way you want in your example, and make sure you have permissions to get to it, or you can run this instead to specify the original file:

mongod -f /usr/local/Cellar/mongodb/2.4.6/mongod.conf