Reputation: 89
I have a problem when server start mongodb
user@-VirtualBox:~$ mongo MongoDB shell version: 2.4.9 connecting to: test Sun May 8 22:10:13.641 Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:145 exception: connect failed
how resolved this problem ?
Upvotes: 3
Views: 1908
Reputation: 21
Looks like your port is already in use, try changing the port number other than 27017. Then start first with 'mongod' command which keep running in background after than run 'mongo'. this one worked for me on my mac
Find "usr/local/etc" dir In "etc" folder find "mongod.conf" In the file I had to set the bindIp configuration item to 0.0.0.0, i changed port to 27020
# network interfaces
net:
port: 27020
bindIp: 0.0.0.0
run following:
mongod --config /usr/local/etc/mongod.conf
then run following by opening new tab in terminal:
> mongo --port 27020
Hope this works for you.
Upvotes: 0
Reputation: 1911
I had the same problem. Looking into MongoDB log file, located in /var/log/mongodb/mongodb.log
, explained the reason - in my case it was:
ERROR: Insufficient free space for journal files
Please make at least 3379MB available in /var/lib/mongodb/journal or use --smallfiles
Upvotes: 2