CentOS 5.x Linux with MongoDB 2.0.1 (tried main and legacy-static)
MongoDB is running:
root 31664 1.5 1.4 81848 11148 ? Sl 18:40 0:
On Ubuntu:
Wed Jan 27 10:21:32 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:84 exception: connect failed
Solution
look for if mongodb is running by following command:
ps -ef | grep mongo
If mongo is not running you get:
vimal 1806 1698 0 10:11 pts/0 00:00:00 grep --color=auto mongo
You are seeing that the mongo daemon is not there.
Then start it through configuration file(with root priev):
root@vimal:/data# mongod --config /etc/mongodb.conf &
[1] 2131
root@vimal:/data# all output going to: /var/log/mongodb/mongodb.log
you can see the other details:
root@vimal:~# more /etc/mongodb.conf
Open a new terminal to see the result of mongod --config /etc/mongodb.conf & then type mongo. It should be running or grep
root@vimal:/data# ps -ef | grep mongo
root 3153 1 2 11:39 ? 00:00:23 mongod --config /etc/mongodb.conf
root 3772 3489 0 11:55 pts/1 00:00:00 grep --color=auto mongo
NOW
root@vimal:/data# mongo
MongoDB shell version: 2.0.4
connecting to: test
you get the mongoDB shell
This is not the end of story. I will post the repair method so that it starts automatically every time, most development machine shutdowns every day and the VM must have mongo started automatically at next boot.