Compass can't connect to mongodb running in docker

I’m running mongodb instance in docker:
docker run --name mongodb -d -p 27017:27017 mongo

When I try to connect to the instance from Compass v: 1.23.0:
mongodb://localhost:27017/admin

Compass fail to connect with error connection <monitor> to 127.0.0.1:27017 closed. but I can connect to the db from my nodejs running on host.

Please help.

1 Like

Have you whitelisted your IP?
or could be some firewall issues
Please check this link.Different fixes given in it

1 Like

That’s unexpected, and I can’t reproduce it. If I run

docker run --name mongodb -d -p 27017:27017 mongo

in my terminal Compass connects with no issues. Can I see a screenshot of the Compass connection screen?

4 Likes

A post was split to a new topic: Can’t connect after upgrading to Compass 1.24.1