Mongodb: Failed to connect to 127.0.0.1:27017, rea

2019-01-08 06:39发布

Here is my mongod.cfg file:

bind_ip = 127.0.0.1
dbpath = C:\mongodb\data\db
logpath = C:\mongodb\log\mongo-server.log
verbose=v

Here is my mongod service command:

mongod -f c:\mongodb\mongod.cfg --install

I have installed MongoDB about a week ago and it all worked fine, however today when I ran mongo command I got the following 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

How can I fix that? I use Windows 8.1

Solution:

I forgot to start mongodb service with this command:

net start mongodb

Improved solution:

1) Change directory to root drive C:\, and type the command below into an admin cmd prompt window,

C:\mongodb\bin\mongod.exe --config c:\mongodb\mongod.cfg --install

2) Then type net start MongoDB after which you should see the following message:

"The Mongo DB service was started successfully"

3) Then go to the control panel Start>Administrative Tools>Services, scroll down to MongoDB in the list of services and change start up type to automatic, if you so desire. Press OK.

4) Finally type C:\mongodb\bin\mongo.exe and you should be connected to the Mongo test DB.

Reference: https://www.youtube.com/watch?v=-mik4dPArCU

17条回答
闹够了就滚
2楼-- · 2019-01-08 07:13

Point to your mongodb instalation e.g C:\Program Files\MongoDB\Serve\bin and run mongod.exe so you can open connection to 127.0.0.1:27017.

查看更多
够拽才男人
3楼-- · 2019-01-08 07:15

The Port is not open. Thats why the machine refuses communication

查看更多
放我归山
4楼-- · 2019-01-08 07:15

mongodb 2.6.8 on windows7 32bits you only need create a folder c:/data/db execute mongod, and execute mongo

查看更多
ら.Afraid
5楼-- · 2019-01-08 07:16

Change file permission to 755 for the file:

/var/lib/mongodb/mongod.lock
查看更多
一纸荒年 Trace。
6楼-- · 2019-01-08 07:16

first you run the command mongod and check weather the port 27017 has started or not if yes then hit the command mongo....and database will start.

查看更多
一纸荒年 Trace。
7楼-- · 2019-01-08 07:18

Try this, it worked for me.

mongod --storageEngine=mmpav1
查看更多
登录 后发表回答