MongoDB window closes automatically when I try to open MongoDB window closes automatically when I try to open mongodb mongodb

MongoDB window closes automatically when I try to open


from doc:

MongoDB requires a data directory to store all data. MongoDB’s default data directory path is \data\db. Create this folder using the following commands from a Command Prompt:

md \data\db

You can specify an alternate path for data files using the --dbpath option to mongod.exe, for example:

C:\mongodb\bin\mongod.exe --dbpath d:\test\mongodb\data

The reason of your problem is that you don't have that data directory.


Create a folder named 'data' with sub-folder 'db' in the root of the folder where your MongoDB Server is installed.

Like in my case, it was installed on C:/Program Files/MongoDB/ and the mongod.exe, mongo.exe resides in C:/Program Files/MongoDB/Server/4.0/bin/.

So, I created a folder namely "data" and a sub-folder in it namely "db".

C:/data/db

Sometimes, there might be a chance that "data" folder already exists in the root drive. Then, just create a sub-folder named "db" in it.

After all of this, close mongod.exe & mongo.exe if running. And open them again in order to see if the problem is gone! I hope that solves the problem.


As laike9m said, MongoDB requires the directory data/db to be created. I just solved the same problem and I did it by creating the directory in "C:/ " (working on windows).