I have installed MongoDb, on WSL using the steps from the official docs here.

When i issue the command sudo service mongod start i get the following message mongod: unrecognized service.

I've tried troubleshooting using these stackoverflow answers. I got it starting using one of the commands sudo mongod --fork -f /etc/mongod.conf

However I cannot stop mongod using sudo service mongod stop. In fact mongod keeps running even after i close WSL. Is the documentation wrong? Or am i doing something wrong? Why wont the commands listed in the docs work?

If I keep using the above command to start mongodb will it affect the data that i store?

2 Answers 2


I was able to fix the

mongod: unrecognized service

issue by performing the following tasks:

sudo nano /etc/init.d/mongod

then copy and paste the content from this url and save it (you can use vim or any other text editor)

After that give executable permission

sudo chmod +x /etc/init.d/mongod

Now you will be able to start the service by following command

sudo service mongod start
  • 2
    This works with the installation instructions in the official MongoDB documents which install the mongodb-org package. You need the additional instructions if you are using WSL Ubuntu because somehow the service is not created. Doing "sudo apt-get install mongodb" installs a totally seperate MongoDB package, which may not be as updated as the official one.
    – Aaron Gong
    Apr 19, 2020 at 15:59
  • @AaronGong you are absolutely right
    – Roaim
    Apr 19, 2020 at 22:03
  • 2
    confirming this works with latest official instructions for mongo 4.4, wsl2 and ubuntu 20.
    – Gabe Rogan
    Oct 17, 2020 at 22:39
  • in the latest wsl2, if i could not find the daemon mongd instead tried mongodb and it worked, also the file was already there in etc/init.d/mongodb not needed to copy it from the github. Thanks :)
    – theredcap
    Feb 21, 2021 at 13:04
  • tried this but it fails. [sudo] password for deepak: * Starting database mongod [fail] Oct 11, 2023 at 10:38

Here's a very important (blockquoted with a red background, no less!) excerpt from the exact link to the MongoDB docs you gave:

MongoDB does not support the Windows Subsystem for Linux (WSL).

However, it should still work, they just won't support it and the version they provide in the package mongodb-org won't work right. I suggest following Microsoft's guide located here which is part of a larger Python guide. Find the "Install MongoDB" section about halfway down the page. Note that the service is named mongodb here and not mongod.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .