I'm working on a project that uses a mongo database running on docker.
When I run the project on windows 10, I can perfectly connect to my db via Mongo Compass using the standard connection string: mongodb://localhost:27017/?readPreference=primary&appname=MongoDB%20Compass&ssl=false
.
However, running the exact same configuration on WSL2 makes it impossible connecting to the database via Mongo Compass. However, the database runs as expected, and the app works fine - it is just the Mongo Compass <> WSL2 connections that are not working. In order to connect with my WSL2 database I've tried this two connection strings:
mongodb://localhost:27017/?readPreference=primary&appname=MongoDB%20Compass&ssl=false
mongodb://0.0.0.1:27017/?readPreference=primary&appname=MongoDB%20Compass&ssl=false
For both cases, Mongo Compass will show DBs running on Windows 10, not on WSL2. Using the Windows 10 mongo shell doesn't list my WSL2 db, neither.
Also, my docker container running on WSL2 seems to be binding the correct port: 0.0.0.0:27017->27017/tcp
.
Any ideas would be very appreciated.