I’m on windows 11. MongoDB compass is installed on Windows. I have my mongodb on Ubuntu using wsl. I started a docker container using the following docker-compose file below and after starting the docker container I’m able to use mongosh in the terminal and see my dbs in linux. But when I use Compass I can’t see the right databases (I’m connecting to localhost:27017. This is the first time that I am using wsl and docker but any help is appreciated!
docker-compose
One possibility is that you have one instance of mongodb on windows that was started before you started the docker version.
The mongosh on docker connects to the docker instance. The Compass on Windows connects to the windows instance. Search and terminate the Windows instance with the task manager. Once the windows instance is terminated, compass should be able to connect.
I do not know why because I did not really investigate but in some occasions, I have seen windows allowing more that one process to listen to a given port. The second one being in some sort of hot standby that would receive connection once the first one terminates.
Thank you that was very helpful. I used netstat -ab on Windows and found that there was another mongod.exe service running and using the same port. I don’t know why but Windows had that service set to automatic. So I disabled it and Compass now can see the collections from my Docker service. Replying so other people can see this in the future.