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

前端 未结 14 1721
渐次进展
渐次进展 2020-12-02 10:39

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

14条回答
  •  醉酒成梦
    2020-12-02 11:26

    I was getting a similar error when I was trying to start my mongo db via cmd. However the difference was I had a config file which has the path to the db and log folders and wanted to use the same. I was using mongo few days back and it was running fine but when I started using it again today it was giving me the error :

    2015-05-27T10:33:22.820-0400 I CONTROL  Hotfix KB2731284 or later update is   installed, no need to zero-out data files
    MongoDB shell version: 3.0.2
    connecting to: test
    2015-05-27T10:33:23.854-0400 W NETWORK  Failed to connect to 27.0.0.1:27017, reason: errno:10061 No connection could be made because the target machine actively refused it.
    2015-05-27T10:33:23.857-0400 E QUERY    Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at connect src/mongo/shell/mongo.js:179:14) at (connect):1:6 at src/mongo/shell/mongo.js:179 exception: connect failed
    

    Here's how I fixed it :

    1. Open cmd as admin and navigate to the bin folder of your MongoDB and type : mongod --config --install
    2. Now start your mongo db service : net start mongodb you should get a message which says : The MongoDB service was started successfully.
    3. close this command prompt and open another one as admin, navigate to the bin folder once again and type mongo

    This will connect you to the mongodb test.

    Press ctrl+c anytime to exit.

    Hope this helps.

提交回复
热议问题