Search code examples
mongodbmongodb-compass

MongoDB Compass forces me to enter Replica Set Name when trying to connect to my local DB. Can I avoid this?


EDIT:

Not sure what I've done differently (again, these are my first steps with all of this), but now I don't get the error message I got before. Instead though, it just tries to make the connection and I get

Server selection timed out after 30000 ms

After some time.

ORIGINAL:

I am new to using MongoDB - currently taking a back end course online.

It seems that Compass has changed their interface for adding a new connection, lately, and maybe some business logic, because all guides I find use the previous one.

Specifically, when adding a new connection, in the guides I read, they leave Replica Set Name empty. When I try to do that, I get an error saying Incomplete key value pair for option.

I tried just calling it localhost and it "works", but I don't see any of my DBs. If I connect with Robo 3t I can see them.

Is it a wrong Replica Set Name that's preventing me from deeing the DBs? Or am I doing something else wrong?

My settings for when trying to connect are:

Hostname : `localhost`
port : 27017
SRV record : I leave it off
Authentication : None
Replica Set Name : localhost
Read preferences : Primary
SSl : none
SSL tunnel : None

Solution

  • It appears that Compass requires a replica set name to be specified, based on the following message I get when I specify a single host which happens to be a secondary:

    An error occurred while loading navigation: 'not master and slaveOk=false': It is recommended to change your read preference in the connection dialog to Primary Preferred or Secondary Preferred or provide a replica set name for a full topology connection.

    "Server selection timed out" can mean different things:

    • There isn't a database running.
    • The database is running but you entered the wrong port number.
    • Compass attempted to perform a specific operation which required a certain server type (e.g. a primary or a secondary). The database is running and there's a server listening at the port you specified, but it is of the wrong type.

    Hard to say which of these is the case just going by the error message.