After I have started Mongo using mongod.exe on a Windows 7 machine, I tried to start the mongo shell that failed with the error:
Failed to connect to 127.0.0.1:27017, reason: errno:10061 No connection could be made because the target machine actively refused it.
...
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
In the CMD where I running the mongod the output is:
C:\Users\Vera>mongod --dbpath c:\mongodb\mongodata
2014-05-18T17:10:10.135-0300 [initandlisten] MongoDB starting : pid=3296 port=27017 dbpath=c:\mongodb\mongodata 64-bit host=Vera-PC
2014-05-18T17:10:10.136-0300 [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2014-05-18T17:10:10.136-0300 [initandlisten] db version v2.6.1
2014-05-18T17:10:10.136-0300 [initandlisten] git version: 4b95b086d2374bdcfcdf2249272fb552c9c726e8
2014-05-18T17:10:10.136-0300 [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1')
BOOST_LIB_VERSION=1_49
2014-05-18T17:10:10.136-0300 [initandlisten] allocator: system
2014-05-18T17:10:10.136-0300 [initandlisten] options: { storage: { dbPath: "c:\mongodb\mongodata" } }
2014-05-18T17:10:10.242-0300 [initandlisten] journal dir=c:\mongodb\mongodata\journal
2014-05-18T17:10:10.243-0300 [initandlisten] recover : no journal files present, no recovery needed
2014-05-18T17:10:11.077-0300 [initandlisten] waiting for connections on port 27017
Any suggestion how to fix this issue?
Ensure that your MongoDB instance is running: Compass must connect to a running MongoDB instance. Also check you have installed MongoDB and have a running mongod process. You should also check that the port where MongoDB is running matches the port you provide in the compass connect.
Here's how I fixed it : Open cmd as admin and navigate to the bin folder of your MongoDB and type : mongod --config <path to your config file> --install. Now start your mongo db service : net start mongodb you should get a message which says : The MongoDB service was started successfully.
I got the same error and fixed it with:
1) mkdir c:\data
2) cd data
3) mongod -dbpath .
4) Now in another command window I was able to connect from my client using the mongo
command.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With