Recently, while doing some experimentation with MongoDB I noticed that my Spring app would no longer connect to mongo with the old WSL1 configuration. After some digging I was able to reconnect my app running in WSL2 to the Mongo service running on the Windows side. The following steps should get packets flowing:
-
Allow packets through the firewall by firing up a Powershell console and issuing:
New-NetFirewallRule -DisplayName "MongoDB from WSL2" -InterfaceAlias "vEthernet (WSL)" -Direction Inbound -Protocol TCP -LocalPort 27017 -Action Allow
-
Reconfigure Mongo to listen for requests on all interfaces, as this is just for local development, by editing the mongod.cfg line:
[Read More]