When ever I try to connect to mongo db I always get this error as below.
MongoDB shell version: 2.4.3 connecting to: test Fri Apr 26 14:31:46.941 JavaScript execution f
I had the same issue, In my case there was a mismatch of ipaddress in mongo config
~# mongo
MongoDB shell version: 2.6.7
connecting to: test
2015-02-02T17:48:52.302+0530 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2015-02-02T17:48:52.303+0530 Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146
exception: connect failed
When I checked my configuration file, I have specified the bind address to eth0 ip(10.8.10.111) not loopback address(127.0.0.1), So I have changed the ip address to loopback as like bind_ip = 127.0.0.1
in /etc/mongod.conf file and restart it with service mongod restart
, finally works
# mongo
MongoDB shell version: 2.6.7
connecting to: test
>
This is due to locking of Mongodb
sudo rm /var/lib/mongodb/mongod.lock
sudo service mongodb restart
If any one is facing the problem in windows machine then follow the steps.
I met with this problem too. And I figured it out by the following way:
First, open the terminal and write
mongod --dbpath {your project's path}
Second, open a new terminal and enter your project's path, write
mongo
Then it runs successfully
with new version of mongodb, this issue got resolved.