Windows was unable to start mongodb service on local machine. View the system event log for more information
I am using Windows 32-bit machine
and tried to start MongoDB service from Windows> Services as shown below.
However, I am unable to start the MongoDB service and is throwing the following error.
When I try to use the cmd prompt, I get 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 has actively refused it.
Error: Could not connect to server 127.0.0.1:27017 <127.0.0.1>, connection attempt failed.
source to share
If anyone else comes across this issue, just read your log files and you should be able to find the problem, for me after trying to install it inside the wamp directory when starting the MongoDB service it gave me the same error message, I went to the logs and found out, what I am missing is a directory inside my data directory which is called db
as soon as I created this directory the service works fine.
source to share
Removing mongod.lock didn't work for me, repair didn't help either. In my case it was due to corruption of one of the database, I moved all the dbs to a different directory and then copied them one by one and restarted the mongodb service to figure out which db file was corrupted. This is definitely a MongoDb bug
source to share
So I just had the same issue running on Windows 10. The reason MongoDB would not start was because the data and log path was not set correctly. This has already been pointed out, but my solution is different. Take a look at C:\Program Files\MongoDB\Server\4.0\bin
(or where your mongoDB is installed). There is a configuration file called mongod.cfg
. Check that
storage:
dbPath:
and
systemLog:
path:
Set to whatever you want. In my case, these were% MONGODBPATH% environment variables or similar that were not set on 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.
source to share
I had the same error message. Try looking for mongodb log files and see the latest entries. My problem was clearly outlined there, 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., terminated
source to share
For on-site demand:
There was a "npm:" in last line of mongodb configuration file which is located in the installation folder bin\mongod.cfg
I commented out this line and started the service and it works like a charm.
I concluded by running mongodb service command from windows command prompt (cmd) and got an error.
ran the following on the command line:
C:\Program Files\MongoDB\Server\4.2\bin\mongod.exe --config "C:\Program Files\MongoDB\Server\4.2\bin\mongod.cfg" --service
source to share