while trying this mongo command in ubuntu I am getting this error.
ritzysystem@ritzysystem-Satellite-L55-A:~$ mongo
MongoDB shell version: 2.6.1
thank you everyone I tried running mongo it was not running finally I found there was no space in my hard disc I emptied some of the space and finally re installed it the same installation procedure as followed to install as given in mongodb docs finally restarted the server and it is running.
https://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu
I understand the question is with regards to Ubuntu.
But if you're getting the same error on a Mac and don't want $ sudo mongod
running on a separate tab, you can do the following to fix the connection error, if you have Homebrew -
brew services start mongodb
Based on the answer from this thread - Cannot connect to mongodb errno:61 Connection refused
In my case the problem was caused due to an apparent lost of permission over mongodb.lock file. I could solve the problem changing the permission with the following command :
sudo chown mongodb:mongodb /var/lib/mongodb/mongodb.lock
There follows my investigation:
Follow this simple steps; (Works on MAC OS too)
Open terminal and run sudo mongod
Open a new terminal tab(Don't close step 1 tab) and run sudo mongo
That's all
In my case the error was due to missing /data/db folder which the mongodb uses to store your data. Please type this command $sudo mongod
in your terminal. If the error message is something like :
missing data/db folder error
Simply create the folder and you are good to go.
Probably you don't have space in your hard drive.
Check it by typing in the promt df -h
Please note that mongo might fail even with 3gb available in the corresponding partition. For details, you might want to check the log: cat /var/log/mongodb/mongod.log