Error in creating a new database with Compass: Secondary is not writable

I created a new Atlas cluster, named Cluster0, a new MongoDB user, and allowed connections from anywhere in the IP Whitelist section.
I am using compass.
In the connection configuration, I provide as hostname the name of my secondary replica:
cluster0-shard-00-02-mpoaq.mongodb.net
I choose the authentication with Username and password:
m001-student
m001-mongodb-basics

Note that in the security section of the Atlas cluster, this user has the following role:
readWriteAnyDatabase

The connection to the cluster is successful, but once I try to create a new database, compass displays an error:

Single connection to server type: Secondary is not writable

Any help is appreciated

AFAIK, write operations can be done only to primary node of the cluster/replica set. As your message shows, it seems you are connected to secondary node.

Hi Manish, thanks for the reply.
I am trying to connect to the primary, but Compass stucks in Loading Navigation…

you mean connecting to primary takes too long?

The process stucks endlessly in Loading Navigation.

switching to another network solved the problem

1 Like