3
votes

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 ?

2
have you started mongodb service? if not please start it using service mongod startSatya
user@-VirtualBox:~$ sudo start mongod mongod start/running, process 9129 user@-VirtualBox:~$ sudo status mongod mongod stop/waiting I did not understand why it is closed?? emile01
do a sudo ps -ef | grep mongod and kill all the processes listed there and then a fresh startSatya
that's what I user@-VirtualBox:~$ sudo ps -ef | grep mongod user 9160 8986 0 22:24 pts/1 00:00:00 grep --color=auto mongod after another server start the same result of the last command emile01
Here the contents of the file mongodb.con # mongod.conf # for documentation of all options, see: # Where and how to store data. storage: dbPath: /var/lib/mongodb journal: enabled: true # engine: # mmapv1: # wiredTiger: # where to write logging data. systemLog: destination: file logAppend: true path: /var/log/mongodb/mongod.log # network interfaces net: port: 27017 bindIp: 127.0.0.1 emile01

2 Answers

2
votes

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
0
votes

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.