MongoDB on a Windows 7 machine: No connection could be made

initializationmongodb

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?

Best Answer

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.

Related Topic