"Failed to connect to 127.0.0.1:27017, Reason: Errno:111 Connection refused" starting mongodb

Asked

Viewed 4,847 times

3

I installed mongodb as suggested on the official website(*), 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 someone help me with some solution?

1 answer

3


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

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

Defaults Mongodb to /data/db to 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 file . lock

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

2) repair the mongodb

mongod –repair

3) start mongodb

sudo service mongodb start 

4) start Mongo client

mongo

For more Details take a look at http://shakthydoss.com/error-couldnt-connect-to-server-127-0-0-127017-srcmongoshellmongo-js-exception-connect-failed/

  • Otto, I reviewed my last reply

  • Dear Otto, I appreciate the help. I was able to solve it with your help and the help of other posts. First I changed the dbpath to my folder /home/username/data/db, because my directory / was not enough space, then I gave chown to the mongodb user in the dbpath folder and I was able to start the service. I appreciate everyone’s help, problem solved.

  • opa se posso ajudar em algo já ótimo da um plus ai :D

Browser other questions tagged

You are not signed in. Login or sign up in order to post.