Mudassir Aqeel Ahmed
Mudassir Aqeel Ahmed

Reputation: 61

unable to start MongoDB server

I installed MongoDB in wsl using the official windows document here. I have created a path and can start the a DB instance using

sudo mongod --dbpath ~/data/db

but after following the docs further and adding the init script from here to start MongoDB as a service, and running this command

sudo service mongodb start

returns output:

* Starting database mongod                                                                                                             [fail] 

and as expected when I run,

sudo service mongodb status

I have the output

* Checking status of database mongod                                                                                                          
* apparently not running
                                                                                                                                   [fail]

now, how do I solve this?

Upvotes: 5

Views: 3524

Answers (2)

MaxySpark
MaxySpark

Reputation: 565

I was getting the same error.

I think owner for this file was root.

when I checked ls -l inside /var/run directory I got this

drwxrwxrwt 2 root    root     40 Jan  2 19:53 lock
drwxr-xr-x 2 mongodb mongodb  60 Jan  2 20:16 mongodb
-rw-r--r-- 1 root    root     6 Jan  2 20:35 mongod.pid
drwxr-xr-x 2 root    root     40 Jan  2 20:00 needrestart
drwxrwxrwt 2 root    root     40 Jan  2 19:53 shm
drwx--x--x 3 root    root     60 Jan  2 19:53 sudo
drwxr-xr-x 2 root    root     40 Jan  2 19:53 user
drwxr-xr-x 2 root    root    140 Jan  2 20:19 WSL

sudo chown mongodb:mongodb /var/run/mongod.pid

after running this issue was resolved

enter image description here

Upvotes: 4

oddball
oddball

Reputation: 333

I suppose you do something like this

wget -qO - https://raw.githubusercontent.com/mongodb/mongo/master/debian/init.d > /etc/init.d/mongod && chmod +x /etc/init.d/mongod

I had this problem to. At the time of writing the HEAD of that file seems broken. You can try:

wget -qO - https://raw.githubusercontent.com/mongodb/mongo/cad54eb5ebdff24ecec53b56788cd151d8d64272/debian/init.d > /etc/init.d/mongod && chmod +x /etc/init.d/mongod

to get the previous version

Upvotes: 0

Related Questions