11

I am using Windows 32-bit machine and tried to start MongoDB service from Windows > services as shown below.

enter image description here

However, I am unable to start the MongoDB service from it and throws the following error.

enter image description here

When I try using cmd prompt, I am getting the following error:

Network 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.

enter image description here

Community
  • 1
  • 1
Prashanth Sams
  • 19,677
  • 20
  • 102
  • 125

15 Answers15

15

I had same an issue.

Try to remove mongod.lock file from your Mongo data directory.

For example mine is "C:\Program Files\MongoDB\Data\mongod.lock" and after deleting file start the MongoDB service and it's work like charm.

Yogesh Patel
  • 672
  • 4
  • 9
  • 2
    I found it here: C:\mongodb\data\db. I read the log files as suggested below and saw this: 2018-03-27T14:14:17.296-0700 [initandlisten] ERROR: Insufficient free space for journal files 2018-03-27T14:14:17.296-0700 [initandlisten] Please make at least 3379MB available in C:\mongodb\data\db\journal or use --smallfiles 2018-03-27T14:14:17.296-0700 [initandlisten] – Scott Izu Mar 27 '18 at 21:13
6

In case someone else is running into this problem, just read your Log files and you will be able to find the problem, for me after trying to install it inside wamp directory when I run the MongoDB service it gave me the same error message, I went to the logs and find out that I was missing a directory inside my data directory which is called db, once I have created this directory the service run perfectly.

  • Thanks this helped me. Turns out in my conf, the directory pointing to the logs file didnt exist on my machine, and i needed to set it to where my logs were located. – element11 Oct 17 '17 at 16:23
4

MongoDB uses a default folder to store its files. On Windows, the default location is C:\data\db.

Maybe that folder doesn´t exist. In that case just creat it or change the default location of Mongo service using the --dbpath command-line flag.

belyid
  • 841
  • 2
  • 12
  • 28
  • When I tried running `net start MongoDB` I had this error: `The MongoDB service is starting. The MongoDB service could not be started. A service specific error occurred: 100. More help is available by typing NET HELPMSG 3547.` I created `C:\data\db` and then when I ran `net start MongoDB` it said `The MongoDB service is starting. The MongoDB service was started successfully.` – Jesus is Lord Sep 18 '17 at 23:12
  • 1
    @WordsLikeJared Glad to help :-) – belyid Sep 20 '17 at 08:44
3

So I just had the same problem, running on Windows 10. The reason why MongoDB didn't start was because the path to the data and logs was not correctly set. This has already been pointed out, but my solution is different. Look in C:\Program Files\MongoDB\Server\4.0\bin (or wherever your mongoDB is installed). There is a config file called mongod.cfg. Check that

storage:
  dbPath:

and

systemLog:
  path:  

Is set to what you want. In my case, it was using environment variables %MONGODBPATH% or similar that was not set by Windows. By default, the log and data should point to C:\Program Files\MongoDB\Server\4.0\data and C:\Program Files\MongoDB\Server\4.0\log\mongod.log respectively.

Zorobay
  • 557
  • 1
  • 6
  • 23
2

There was a npm: in last line of mongodb configuration file which is located in the installation folder in the bin\mongod.cfg

I commented out that line and started the service and it is working like charm.

I concluded this by running the mongodb service command from windows command line(cmd) and I got an error.

I ran this to spot the error:

C:\Program Files\MongoDB\Server\4.2\bin\mongod.exe --config "C:\Program Files\MongoDB\Server\4.2\bin\mongod.cfg" --service

Abbas Hosseini
  • 1,545
  • 8
  • 21
1

mongod.lock deletion did not helped me, repair did not help either. In my case it was due to one of database happened to be corrupted, I moved all dbs to another directory and then copied them back one by one and re-starting mongodb service to figure out what db file is corrupted. It's definitely MongoDb bug

YMC
  • 4,925
  • 7
  • 53
  • 83
0

I had the same error message. Try to locate the mongodb log files and look at the last entries. My issue was clearly stated there, a missing directory :

2019-01-29T16:59:44.424+0100 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory C:\wamp64\bin\mongodb\mongodb-win32-x86_64-2008plus-ssl-3.6.10\data\db not found., terminating

standac
  • 1,027
  • 1
  • 11
  • 26
0

The advice of checking the log was what helped me. In this case: The MongoDB service could not be started. A service specific error occurred: 100 turns out I had a problem with some databases created with WiredTiger while the mongod.cfg specified engine was: mmapv1 So I basically removed the content of the folder c:/data/db/ and then used the command net start MondoBD --repair and worked. Uffff it´s been 2 days.

testfailed
  • 31
  • 2
  • 5
0

I'm here a bit late, very late actually. But may it works something out for the ones facing this issue now. Mongodb configuration file in Windows OS is under 'C:\Program Files\MongoDB\Server\%YOUR MONGO VERSION%'.

I had changed this file and manipulated the bindip field, so I was getting the same error. It should be 127.0.0.1 or your machine's IP address which you can find it by 'ipconfig/all' command in cmd. So I fixed bindip and the service starts with no problems.

Jan Sršeň
  • 1,045
  • 3
  • 23
  • 46
AliAndArdDev
  • 181
  • 1
  • 8
0

stuck on the same issue, but got the solution by hit and trial, just create a new folder for path "C:\data\db" then go to your command prompt and type 'mongod', your database server will start.

0

For me it was a port problem :

just search and kill the process using the port 27017

for linux : https://bobcares.com/blog/mongodb-error-code-48/

for windows : How do I kill the process currently using a port on localhost in Windows?

MonirRouissi
  • 549
  • 8
  • 7
0

I have found out that Visual C++ Redistributable was missing in my Windows 7 Machine. After installing it worked.

0

For Windows 10 users specify database location, if don't know create the below-mentioned directory and always use this

  • open cmd
mkdir C:\users\{username}\data
cd C:\users\{username}\data
mongod --dbpath .

start mongodb server

  • open cmd
mongod --dbpath C:\users\{username}\data

stop mongodb

  • open cmd
mongo

if server is running, run:

use admin
db.shutdownServer()
quit()
Antoine
  • 1,393
  • 4
  • 20
  • 26
0

In my case, this happened because I did not stop MongoDB from docker. after I stopped the process the error was gone.

Gregoire Cattan
  • 555
  • 7
  • 19
Yonas
  • 1
0

In my case, it was the docker with MongoDB running on the same port. So after I stopped the container, the service is then successfully starting.

Dmitriy Popov
  • 2,150
  • 3
  • 25
  • 34