You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After installation is complete I try to run mongodb with
sudo service mongod start
but have follow error
User@DESKTOP-TPQIRNP:/mnt/c/Users/User$ sudo service mongod start
initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
mongod: unrecognized service
But If I install MongoDB with sudo apt-get install mongodb I can run it with sudo service mongodb start and this work. But with sudo apt-get install mongodb will be installed old 2.x.x version of MongoDB
How to install the latest stable version of MongoDB (3.x.x) without errors on Windows Linux Subsystem ?
Reacted by Alberto Spina, alonextou, Michael Ikechi, Musa Haidari, Luiz Victor, paul, Chris Lohmann, Wirasak Moukrong, icetea, Vasek Codey Vlcek and 1 more
Xander Smeets (@XSmeets)services are unimplemented for now but if I install mongodb with sudo apt-get install mongodb sudo service mongod start will work
Reacted by Lucas Wyland, Jaanus Varus, Max de Croy, Eduard A. Ragimov, Alberto Spina, gregperez, Henrique Campos, Christian Quispe H, Athanasios Skrepetos, Elias Schoof and 1 more
Xander Smeets (@XSmeets) I wrote in my issue that everything is working fine (with install mongodb with sudo apt-get install mongodb and run sudo service mongodb start). You can check it yourself if you have Windows 10 with Linux Subsystem. And if you try to connect to MongoDB with Mongoose It will also work well. And about Upstart #791 (comment) I have problem only with install latest stable MongoDB from official instructions
Reacted by xtianus79, Jaanus Varus, John Vornberger, Ginpei, lizalukyanenko, Hoàng Tiến Đạt, Vasek Codey Vlcek and luanthanhng
Xander Smeets (@XSmeets) -- you are technically correct that Upstart is responsible for starting applications, but not in the way that you imply here. The service command doesn't call Upstart. Quite the opposite -- Upstart calls the service command when your machine boots.
The absence of Upstart means that mongodb will not automatically start on reboot; @Zx-EvM will have to re-run sudo service mongodb start to start using MongoDB again. However, it works just fine otherwise.
nginx and OpenSSH both do fail currently, but not because of Upstart. nginx fails due to an issue related to IPv6 support; see #68 for details and a workaround. OpenSSH fails due to lack of chroot support among other issues; there's discussion on #300 , and the workaround is documented on this forum post. In both cases, the failures are not due to issues involving Upstart.
Reacted by therealkenc, Robert Noble and xtianus79
If you get the initctl error message about not being able to talk to upstart, and the service doesn't start, you might want to look for the script in /etc/init.d, which is (usually) a standard bash script. Run it like any other bash script, with start as a parameter. In other words, remove the word "service" from the command and call the script by its full path. Then it won't matter if upstart or service isn't implemented fully.
I've been doing that with sshd, sudo /etc/init.d/ssh start rather than sudo service ssh start . Note that the script is not called sshd, as you might expect.
Your mileage may vary, and there may not be a bash script in /etc/init.d you can run.
If you run the script and then it reports an error, you can be sure it is an error in that script or in the way your service runs. Right now, invoking it with the service command, before services are supported, it's hard to say where the problem is.
The other option is to find the executable for the service/daemon's executable. Frequently there is a way to make it run from a command line (usually for testing, or special applications). That's even more simple than running it from a bash script. If you can get the executable running that way, you can work from there to getting a script working.
Just a comment: right now we are using WSL when many things are broken or not yet implemented. Yes, we all know sudo service mongodb start is the proper way to start it, but since services aren't yet implemented, and we want to get some work done, we look for workarounds. Similarly, if there is a problem getting mongodb runniing in its barest, cleanest implementation, it may be helpful for it to be reported to the WSL folks separate from the issue of not being able to run it as a service.
rodrymbo thanks. If I run MongoDB (which installed using sudo apt-get install mongodb not latest) with sudo /etc/init.d/mongodb start this work without initctl error message. Hm. But if I install MongoDB using official instruction
I'm not familiar enough with upstart or mongodb (yet) to speculate too much.
If you use the first method (sudo apt-get install mongodb, without implementing the repository at repo.mongodb.org), and you do get the mongodb script in /etc/init.d, you could save a copy of it somewhere like your home directory. It will include a line somewhere that does the actual starting of the mongod daemon (most likely). Then if you install from the repo.mongodb.org repository, there's a chance the script you saved may work. If not it may give you clues as to where to find the executable, or what to use in man to learn about it, for example, how to run it without it detaching or becoming a daemon (perhaps -D). I'd guess the daemon executable is mongod, but it's only a guess.
@Zx-EvM -- ah, sorry, I confused your two recent posts.
It looks like the new package really is an Upstart-specific script. That means that you don't start it using sudo service mongod start; you start it with sudo /sbin/start mongod. Which doesn't appear to work right now.
Oddly, though, if I install the old version and then (without removing it) I install the new version, then sudo service mongodb start (which is a script installed by the old package) seems to detect the new version of mongodb instead of the old one, and start it correctly.
$ sudo service mongodb start
initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
* Starting database mongodb [ OK ]
$ mongo
MongoDB shell version: 3.2.8
connecting to: test
2016-08-06T17:01:59.123-0400 E NETWORK [thread1] can't get TCP_KEEPIDLE: errno:22 Invalid argument
2016-08-06T17:01:59.123-0400 E NETWORK [thread1] can't get TCP_KEEPINTVL: errno:22 Invalid argument
> db.version()
3.2.8
>
Reacted by Michael, Kareem Mokhtar, Sithu, Subroto, Leonardo Pinheiro, Sadik Tekin, Alejandro Cerutti, alexander-xu, Arthur Hjorth, Caleb Viola and 10 more
Reacted by alexander-xu, Alexander Malkosh, Huimin Du, Daniel Kmak, Chris Oakley and Eduardo Cunha
Reacted by alexander-xu and Chris Oakley
Reacted by Rhoger Anacleto
Reacted by alexander-xu, Yannis Karakozis, Chris Oakley and Chross
Incidentally, if anyone reading this wants to start mongodb at system start, I've posted a comment on these sshd instructions that I think explains how to do so:
Hey! Sorry, but I'm a bit of a noob and I'm not quite able to to follow all of the instructions you guys have laid out. Is there any way one of you can post an exact set of commands for downloading and getting MongoDb running on WSL? I tried this: sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927 echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list sudo apt-get update sudo apt-get install -y mongodb-org
which threw an error, so I tried again with: sudo service mongodb start
and it's still failing to install. Here's the output of that command: Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.wjm2zfd5JA --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927 echo deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse gpg: "echo" not a key ID: skipping gpg: "deb" not a key ID: skipping gpg: "http://repo.mongodb.org/apt/ubuntu" not a key ID: skipping gpg: "trusty/mongodb-org/3.2" not a key ID: skipping gpg: "multiverse" not a key ID: skipping gpg: requesting key EA312927 from hkp server keyserver.ubuntu.com gpg: key EA312927: public key "MongoDB 3.2 Release Signing Key <[email protected]>" imported gpg: Total number processed: 1 gpg: imported: 1 (RSA: 1)
blake schwartz (@bschwartz757) the only way I managed to make MongoDB works on WSL was to install an old version. sudo apt-get install mongodb on a clean installation. Then just launching sudo mongod. I was unable to use the latest version due to wiredTiger issues
Ah, dang, that's too bad. I'm doing the Mongo University course right now and thought it might be useful to have a working Mongo instance on WSL, but it wouldn't really make sense to do so with an old version.
I guess I'll have to stick with Git Bash for now. Thanks for the response!
Adam Seering (@aseering) how did you actually manage to install the new version, if I might ask? I was able to install using the apt-get command others referenced, but I have version 2.4.9 now. Interested in trying out the solution you mentioned.
Thanks Antonin Cezard (@acezard) I was able to install the old version as you suggested. Still can't get it to run though...
You mean sudo mongod --fork --config /etc/mongod.conf, right?
Correct. Bad combination of typing and then changing mind and pasting what was actually in my terminal. I've fixed up the post. Or even more correctly, "whatever works", laugh.
Michael Farrell (@Mikeysax) Thanks a lot for that tutorial! It helped me get everything working but I'm getting "WARNING: shell and server versions do not match" (shell version v4.0.6, server version: 3.6.3). Restarting the service doesn't work. Any ideas?
Not sure why this solution wasn't commented before.
[a.] It was (quoth: "The other way to go is use Ubuntu's mongodb") and [b.] The ask was for mongodb-org not mongodb. This issue wouldn't even be on the books if the ask was mongodb.
Reacted by a113nw, Minhaj, Satvik Pendem, Chris Lohmann and Aaron Gong
I was able to fix it by performing 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
Reacted by Aaron Gong, Rodrigo Borges de Oliveira, zeyad-khaled, LurnD, Juan David Vallejo Restrepo, 0x104, Andrii Hrushetskyi, Whatseop, Mauricio Robayo, Nicolaus Christian Gozali and 9 more
Reacted by 0x104, Andrii Hrushetskyi, Elias Carvalho and Juan Pablo de la Torre
Reacted by hanh-nguyen411, Juan Pablo de la Torre and tokoshiro5
Reacted by Kamil Kozak, Luis Miguel Mejía Suárez, Andrii Hrushetskyi, Elias Carvalho and Renato Byrro
I was able to fix it by performing 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
This is correct. Somehow for the mongodb-org package (the package described in MongoDB documentation) on WSL Ubuntu (tried on 18.04), the service is not created.
If you use sudo apt-get install mongodb you are actually installing and using a different package which may not have an updated version of MongoDB.
Reacted by SergeyS3, Khasbullah Nukman Zakin, Mike Builds and kitrath
Reacted by Kamil Kozak, Fonziemedia and Khasbullah Nukman Zakin
This article may help. There are 2 packages for ubuntu... mongodb (not sure who created this) and mongodb-org (official). It explains which to use in a little more detail.
to install mongodb before trying my suggested workaround?
I am having this issue too, and I installed mongodb before this. Still getting this fail, and I cannot find anything on how to fix or get the server running.
Reacted by Zac Lucarelli, Byron Molina, craupesantez, YingLLL and Jonathan Richer
I am having this issue too, and I installed mongodb before this. Still getting this fail, and I cannot find anything on how to fix or get the server running.
Check the log file (should be /var/log/mongod.log), if there is something like this,
{"t":{"$date":"2022-06-09T09:48:22.057+08:00"},"s":"E",` "c":"NETWORK", "id":23024, "ctx":"initandlisten","msg":"Failed to unlink socket file","attr":{"path":"/tmp/mongodb-27017.sock","error":"Operation not permitted"}}
Try deleting /tmp/mongodb-27017.sock or change the owner of this file to user mongodb. This works for me.
It may be because of running mongodb manually with mongod command as other users. and the file was created by that user, which causes the mongodb's default user mongodb can not access this file.
Activity
carpet92 commentedon Aug 6, 2016
Xander Smeets (@XSmeets)
services are unimplemented for nowbut if I install mongodb withsudo apt-get install mongodbsudo service mongod start will workcarpet92 commentedon Aug 6, 2016
Xander Smeets (@XSmeets) I wrote in my issue that everything is working fine (with install mongodb with
sudo apt-get install mongodband runsudo service mongodb start). You can check it yourself if you have Windows 10 with Linux Subsystem. And if you try to connect to MongoDB with Mongoose It will also work well. And about Upstart #791 (comment) I have problem only with install latest stable MongoDB from official instructionsaseering commentedon Aug 6, 2016
Xander Smeets (@XSmeets) -- you are technically correct that Upstart is responsible for starting applications, but not in the way that you imply here. The
servicecommand doesn't call Upstart. Quite the opposite -- Upstart calls theservicecommand when your machine boots.The absence of Upstart means that mongodb will not automatically start on reboot; @Zx-EvM will have to re-run
sudo service mongodb startto start using MongoDB again. However, it works just fine otherwise.nginx and OpenSSH both do fail currently, but not because of Upstart. nginx fails due to an issue related to IPv6 support; see #68 for details and a workaround. OpenSSH fails due to lack of chroot support among other issues; there's discussion on #300 , and the workaround is documented on this forum post. In both cases, the failures are not due to issues involving Upstart.
carpet92 commentedon Aug 6, 2016
Adam Seering (@aseering)
Yes. I understand it. but my issue is that for some reason does not work correctly MongoDB (not run) after install as here https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/
rodrymbo commentedon Aug 6, 2016
If you get the initctl error message about not being able to talk to upstart, and the service doesn't start, you might want to look for the script in /etc/init.d, which is (usually) a standard bash script. Run it like any other bash script, with
startas a parameter. In other words, remove the word "service" from the command and call the script by its full path. Then it won't matter ifupstartorserviceisn't implemented fully.I've been doing that with sshd,
sudo /etc/init.d/ssh startrather thansudo service ssh start. Note that the script is not called sshd, as you might expect.Your mileage may vary, and there may not be a bash script in
/etc/init.dyou can run.If you run the script and then it reports an error, you can be sure it is an error in that script or in the way your service runs. Right now, invoking it with the
servicecommand, before services are supported, it's hard to say where the problem is.The other option is to find the executable for the service/daemon's executable. Frequently there is a way to make it run from a command line (usually for testing, or special applications). That's even more simple than running it from a bash script. If you can get the executable running that way, you can work from there to getting a script working.
Just a comment: right now we are using WSL when many things are broken or not yet implemented. Yes, we all know
sudo service mongodb startis the proper way to start it, but since services aren't yet implemented, and we want to get some work done, we look for workarounds. Similarly, if there is a problem getting mongodb runniing in its barest, cleanest implementation, it may be helpful for it to be reported to the WSL folks separate from the issue of not being able to run it as a service.carpet92 commentedon Aug 6, 2016
rodrymbo thanks. If I run MongoDB (which installed using
sudo apt-get install mongodbnot latest) withsudo /etc/init.d/mongodb startthis work without initctl error message. Hm. But if I install MongoDB using official instructionI don't even have any file related mongodb in
/etc/init.ddirectory.rodrymbo commentedon Aug 6, 2016
I'm not familiar enough with upstart or mongodb (yet) to speculate too much.
If you use the first method (
sudo apt-get install mongodb, without implementing the repository at repo.mongodb.org), and you do get the mongodb script in /etc/init.d, you could save a copy of it somewhere like your home directory. It will include a line somewhere that does the actual starting of the mongod daemon (most likely). Then if you install from the repo.mongodb.org repository, there's a chance the script you saved may work. If not it may give you clues as to where to find the executable, or what to use in man to learn about it, for example, how to run it without it detaching or becoming a daemon (perhaps-D). I'd guess the daemon executable is mongod, but it's only a guess.aseering commentedon Aug 6, 2016
@Zx-EvM -- ah, sorry, I confused your two recent posts.
It looks like the new package really is an Upstart-specific script. That means that you don't start it using
sudo service mongod start; you start it withsudo /sbin/start mongod. Which doesn't appear to work right now.Oddly, though, if I install the old version and then (without removing it) I install the new version, then
sudo service mongodb start(which is a script installed by the old package) seems to detect the new version of mongodb instead of the old one, and start it correctly.carpet92 commentedon Aug 6, 2016
Adam Seering (@aseering) oh. Thanks! It's work for me
KEMDAK commentedon Aug 6, 2016
Adam Seering (@aseering) That worked :D thanks.
aseering commentedon Aug 10, 2016
Incidentally, if anyone reading this wants to start mongodb at system start, I've posted a comment on these sshd instructions that I think explains how to do so:
http://wsl-forum.qztc.io/viewtopic.php?f=6&t=10
bschwartz757 commentedon Sep 17, 2016
Hey! Sorry, but I'm a bit of a noob and I'm not quite able to to follow all of the instructions you guys have laid out. Is there any way one of you can post an exact set of commands for downloading and getting MongoDb running on WSL? I tried this:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927 echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list sudo apt-get update sudo apt-get install -y mongodb-orgwhich threw an error, so I tried again with:
sudo service mongodb startand it's still failing to install. Here's the output of that command:
Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.wjm2zfd5JA --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927 echo deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse gpg: "echo" not a key ID: skipping gpg: "deb" not a key ID: skipping gpg: "http://repo.mongodb.org/apt/ubuntu" not a key ID: skipping gpg: "trusty/mongodb-org/3.2" not a key ID: skipping gpg: "multiverse" not a key ID: skipping gpg: requesting key EA312927 from hkp server keyserver.ubuntu.com gpg: key EA312927: public key "MongoDB 3.2 Release Signing Key <[email protected]>" imported gpg: Total number processed: 1 gpg: imported: 1 (RSA: 1)Many thanks!!
acezard commentedon Sep 18, 2016
blake schwartz (@bschwartz757) the only way I managed to make MongoDB works on WSL was to install an old version.
sudo apt-get install mongodbon a clean installation. Then just launchingsudo mongod. I was unable to use the latest version due to wiredTiger issuesbschwartz757 commentedon Sep 18, 2016
Ah, dang, that's too bad. I'm doing the Mongo University course right now and thought it might be useful to have a working Mongo instance on WSL, but it wouldn't really make sense to do so with an old version.
I guess I'll have to stick with Git Bash for now. Thanks for the response!
bschwartz757 commentedon Sep 20, 2016
Adam Seering (@aseering) how did you actually manage to install the new version, if I might ask? I was able to install using the apt-get command others referenced, but I have version 2.4.9 now. Interested in trying out the solution you mentioned.
Thanks Antonin Cezard (@acezard) I was able to install the old version as you suggested. Still can't get it to run though...
27 remaining items
benjaminbauer commentedon Jun 4, 2018
therealkenc Thanks a lot for the hint!
You mean
sudo mongod --fork --config /etc/mongod.conf, right?therealkenc commentedon Jun 4, 2018
Correct. Bad combination of typing and then changing mind and pasting what was actually in my terminal. I've fixed up the post. Or even more correctly, "whatever works", laugh.
Mikeysax commentedon Jun 10, 2018
For anyone wondering how to get the latest mongodb-org working with WSL:
https://gist.github.com/Mikeysax/cc86c30903727c556bcce960f7e4d59b
MajidJafari commentedon Dec 20, 2018
I had also problem installing mongodb on wsl. You might check my answer on another issue related to this one:
https://github.com/Microsoft/WSL/issues/3286#issuecomment-449053033
gigamesh commentedon Mar 7, 2019
Michael Farrell (@Mikeysax) Thanks a lot for that tutorial! It helped me get everything working but I'm getting "WARNING: shell and server versions do not match" (shell version v4.0.6, server version: 3.6.3). Restarting the service doesn't work. Any ideas?
nevergiveup777 commentedon Jun 2, 2019
I had the same problem to install MongoDB on Ubuntu 18.04 (WSL) and I sorted out by just running:
sudo apt-get install mongodbNot sure why this solution wasn't commented before.
Source: https://medium.com/@zhanxucong/installing-mongodb-and-redis-on-wsl-2038a2f6a0a9
therealkenc commentedon Jun 2, 2019
[a.] It was (quoth: "The other way to go is use Ubuntu's
mongodb") and [b.] The ask was for mongodb-org not mongodb. This issue wouldn't even be on the books if the ask was mongodb.Roaim commentedon Apr 9, 2020
I was able to fix it by performing following tasks:
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
Now you will be able to start the service by following command
ais-one commentedon Apr 19, 2020
This is correct. Somehow for the mongodb-org package (the package described in MongoDB documentation) on WSL Ubuntu (tried on 18.04), the service is not created.
If you use sudo apt-get install mongodb you are actually installing and using a different package which may not have an updated version of MongoDB.
bn-l commentedon Feb 1, 2021
I tried this and got this:
ais-one commentedon Feb 6, 2021
I had moved on to using Docker. Since Docker works well with WSL on Windows Home Edition 2004
Roaim commentedon Feb 6, 2021
Actually, you need to install mongodb first then create the service script. Did you follow this tutorial,
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu
to install mongodb before trying my suggested workaround?
ais-one commentedon Feb 7, 2021
This article may help. There are 2 packages for ubuntu... mongodb (not sure who created this) and mongodb-org (official). It explains which to use in a little more detail.
https://dev.to/zenika/setup-mongodb-on-wsl-ubuntu-18-04-167
Scribblets commentedon Feb 12, 2021
I am having this issue too, and I installed mongodb before this. Still getting this fail, and I cannot find anything on how to fix or get the server running.
imjxydhh commentedon Jun 9, 2022
Check the log file (should be /var/log/mongod.log), if there is something like this,
Try deleting
/tmp/mongodb-27017.sockor change the owner of this file to usermongodb. This works for me.It may be because of running mongodb manually with
mongodcommand as other users. and the file was created by that user, which causes the mongodb's default usermongodbcan not access this file.