1
0 Comments

connect to MongoDB from WSL2

Hello!

I switched to WSL2 yesterday and suddenly my web server could not connect to my mongoDB database installed on windows.

I figured it out this morning. Essentially you have to:

  • Run a few commands as listed in this github issue. It essentially restarts a few networking services on the windows host.
  • Create a new inbound rule to allow remote connection to reach the mongo.exe program (beware of restricting the rule to private network only)
  • Change the mongodb config file to allow remote connections to the mongo server.

I wrote a little bit more details on my blog here.

It had been bothering me for a while now, so I am glad I figured it out. I hope it can help someone else. My next step is to have the X11 server to work again (it was fine on WSL1, but not anymore).

on November 30, 2020