Why does the primary node keep changing?

In Compass, I saved the connection details for the Sandbox cluster as instructed. It worked for a few days and then I started getting an error message. I figured out that the primary node had changed. I thought maybe it was a one time thing but it keeps changing and when I load the connection details, I have to check the server string to make sure that what is saved in Compass is still the same as the primary listed in Atlas.

I assume the primary can’t be written to for some reason so the primary designation is being switched to a secondary server. Is this correct? Is there a way to check which server is primary programmatically when trying to connect automatically?

Why? Because the Primary node is a sneaker bugger! :slight_smile:

The course titled “Basic Cluster Administration” covers this. Suggest you take it, it’s quite informative!

If you’re absolutely certain that the Primary keeps changing, I think you should use the “Report an issue” button within the course page to report this problem.

Hi @Jennifer_45288,

Please enter the name of your replica set in the Replica Set Name field and hopefully this should resolve your issue.

19%20PM

Replica set triggers an election in response to a variety of events. In your case the most likely reason could be the secondary members losing connectivity to the primary for more than the configured timeout (10 seconds by default).

You can check this by connecting to your atlas cluster from mongo shell and run the rs.status() function.

Hope it helps!

If you have any other issue, please feel free to get back to us.

Happy Learning :slight_smile:

Thanks,
Shubham Rajan
Curriculum Support Engineer