Can't connect after upgrading to Compass 1.24.1

My Compass for macOS has been running for days and when I just got an update prompt I let it install its update. The first time around the icons in the app were all just squares as if an icon font was missing. It asked me again to install an update, which I did. It didn’t automatically restart, by the way. I started it manually, I can see I am now on version 1.24.1, but I can no longer connect to my MongoDB server running on a different computer as Docker container on the local network. My Node.js app running on my Mac can connect to it without issues, only Compass is struggling.

When I click the “connect” button, it shows the green loading bar at the top and after a few seconds it displays a red error box: getaddrinfo ENOTFOUND 1ec7f415e93f

My connection string: mongodb://10.xxx.xxx.xxx:27017/?readPreference=primary&appname=MongoDB%20Compass&ssl=false

Connecting to Atlas works.

1 Like

Additional information, not sure if it’s useful or not… The Docker container is logging this when I try to connect through Compass:

{"t":{"$date":"2020-12-10T13:15:30.537+00:00"},"s":"I",  "c":"NETWORK",  "id":22943,   "ctx":"listener","msg":"Connection accepted","attr":{"remote":"10.10.10.2:60247","connectionId":887,"connectionCount":6}}
{"t":{"$date":"2020-12-10T13:15:30.541+00:00"},"s":"I",  "c":"NETWORK",  "id":51800,   "ctx":"conn887","msg":"client metadata","attr":{"remote":"10.10.10.2:60247","client":"conn887","doc":{"driver":{"name":"nodejs","version":"3.6.3"},"os":{"type":"Darwin","name":"darwin","architecture":"x64","version":"20.1.0"},"platform":"'Node.js v12.4.0, LE (unified)","application":{"name":"MongoDB Compass"}}}}
{"t":{"$date":"2020-12-10T13:15:30.548+00:00"},"s":"I",  "c":"NETWORK",  "id":22944,   "ctx":"conn887","msg":"Connection ended","attr":{"remote":"10.10.10.2:60247","connectionId":887,"connectionCount":5}}

How do you start the container? Can you share the command you run or the docker/docker-compose file?

Two commands:

docker run --name my-mongodb --restart unless-stopped -d -p 27017:27017 mongo:4 --replSet rs0
docker run -it --rm --link my-mongodb:mongo mongo:4 mongo --host mongo --eval "rs.initiate()"

PS: Connecting with MongoDB shell version v4.2.0 from Mac to Linux/Docker also works without issues: mongo mongodb://10.x.x.x:27017

I can reproduce the problem. Let us look into it.

1 Like

Ok, I think I know what the problem is.

When you initialize the replica set with the default settings, because you are inside docker, the replica set member uses the docker host name, which is unreachable from outside docker, and the latest version of the node driver that Compass uses doesn’t like that.

To work around that, you can initialize the replica set like this:

docker run -it --rm --link my-mongodb:mongo mongo:4 mongo --host mongo --eval "rs.initiate({_id: 'rs0', members: [{_id:1, host:'10.x.x.x:27017'}]})"

where 10.x.x.x is the IP you use when connecting to it from Compass.

That should work.

1 Like

Awesome – it worked! Thank you so much for providing a solution so quickly! :hugs:

2 Likes

I’m having the same issue and would like to know when the fix will be added to a future release?

Hello! The right config should use localhost:27017. I was able to connect via SSH until I updated to 1.24.1.
Now I see:

  1. “Server selection timed out after 30000 ms” in my compass.
  2. “Connection ended” in my mongo logs. So there are no errors.

Could you tell me how to fix this issue?

        {
                "_id" : 0,
                "host" : "localhost:27017",
                "arbiterOnly" : false,
                "buildIndexes" : true,
                "hidden" : false,
                "priority" : 1,
                "tags" : {

                },
                "slaveDelay" : NumberLong(0),
                "votes" : 1
        }

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.