error when connecting to mongodb

1

I have a problem when I want to access the mongo console, I raise the service with brew and when I try to enter the mongo shell I get this error:

MongoDB shell version: 3.2.8
connecting to: test
2016-08-17T08:47:10.650-0300 W NETWORK  [thread1] Failed to connect to 127.0.0.1:27017, reason: errno:61 Connection refused
2016-08-17T08:47:10.650-0300 E QUERY    [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:229:14
@(connect):1:6

If I see the list of services, it appears to me that it is running, but when I see the ports that are being occupied, nothing is in 27017.

I do not think it's an installation error because it used to work.

Does anyone have any ideas?

    
asked by Nitroceluloso 17.08.2016 в 13:57
source

2 answers

0

You comment that "before it worked", then try this solution:

inside the folder \db delete the file mongod.lock

\data\db\mongod.lock

subsequently run

>mongod --repair
    
answered by 17.08.2016 / 15:39
source
1

Remember that before running mongo you need to create the directory for the data and run Mongo Daemon:

mkdir -p /data/db
sudo mongod
    
answered by 17.08.2016 в 14:09