"Failed to connect to 127.0.0.1:27017, reason: errno: 111 Connection refused" starting mongodb

3

I installed mongodb as it suggests on the official website (*), I started the service, but when I tried to use the mongo command on the terminal the following error was returned:

2014-09-17T10:22:29.328-0300 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2014-09-17T10:22:29.329-0300 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

Can anyone help me with some solution?

asked by anonymous 17.09.2014 / 15:36

1 answer

3

Yes, you could create / date / db at the root. The MongoDB documentation suggests the following command for mkdir -p /data/db .

As for your second question, yes as well. Since Mongo Daemon failed to start and is not listening you get the connection error.

MongoDB defaults to / data / db for the data directory. You can override the default by using the --dbpath option in the mongod command.

Or you could do something like this:

1) Remove the .lock file

sudo rm /var/lib/mongodb/mongod.lock 

2) repair mongodb

mongod –repair

3) start mongodb

sudo service mongodb start 

4) start mongo client

mongo

For more details take a look at link

    
17.09.2014 / 15:57