10107 — NotWritablePrimary
replicationwrite
A write was attempted on a member that is not the primary
What is happening?
NotWritablePrimary (formerly NotMaster) is returned when a write operation is sent to a replica set member that is not the current primary. This commonly happens during failovers, when the topology has changed but the driver has not yet detected the new primary.
Common causes
- Primary stepped down or an election occurred
- Driver's server selection has stale topology information
- Application connected directly to a secondary instead of using the replica set URI
- Read preference set to primary but the primary is unreachable, then a write is attempted
- Network partition causing the application to hold a connection to a now-secondary member