I run MongoDB on Mac:
Shave:mongodb_simple Logan$ ./bin/mongod -f conf/mongod.conf
about to fork child process, waiting until server is ready for connections
I encountered this issue on a GCP managed Compute Engine instance.
As this is the top answer on a Google search for the issue, I'll include what worked for me, and is a documented bug as per MongoDB (jira-link)
On linux systems, if the user running mongod does not have a locale set or the locale is misconfigured, mongod fails to start printing a stack trace.
The issue can be resolved by combining a few steps:
sudo apt-get install language-pack-XX
sudo update-locale
Restart your session, and check the same mongo command again
IFF the above doesn't work (it didn't for me), just manually add the following to the file at /etc/default/locale
(ref):
LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8
sudo dpkg-reconfigure locales
That's all, your MongoDB instance should be good to go now!
This worked for me:
run in terminal
sudo rm -rf mongod.lock
export LC_ALL=C
then
sudo mongod --fork --config /xxxx/xx/mongod.conf --logpath /xxx/log/mongodb/mongodb.log
You started and probably shutdown mongo in the wrong way.
1. TO START MONGODB
To start mongo in the background type: mongod --dbpath /data/db --fork --logpath /dev/null
.
/data/db
is the location of the db. If you haven't created one yet => type: mkdir /data/db
--fork
means you want to start mongo in the background - deamon. --logpath /dev/null
means you don't want to log - you can change that by replacing /dev/null
to a path like /var/log/mongo.log
2. TO SHUTDOWN MONGODB
Connect to your mongo by typing: mongo
and then use admin
and db.shutdownServer()
. Like explain in mongoDB
If this technique doesn't work for some reason you can always kill the process.
PID
by typing: lsof -i:27017
assuming your mongodb is running on port 27017kill <PID>
, replace <PID>
by the value you found the previous command. By changing owner to mongodb
for all files under /var/lib/mongodb/
it started working for me:
chown mongodb:mongodb -R /var/lib/mongodb/
Check the ownership of the file /tmp/mongodb-27017.sock
It should be mongod
. I got same error since it was root:root