I have a MongoDB standalone server, which I am converting to a replica set by adding other servers. However, some clients are still connecting to the original server without specifying any other servers or the ?replicaSet= parameter in the URI, and some of these clients insert new documents.

What happens to the documents that are inserted? Will they be propagated correctly to the rest of the replica set? What happens if the original mongo switches to Secondary status and the clients keep trying to insert documents?

1 Answer 1


As long as your clients are connecting to the current replica set primary they will be able to work with documents as usual and those writes will be replicated. This is useful as a transitional approach when upgrading a standalone deployment to a replica set.

However, without a replica set connection string your clients will be unaware of any changes in the replica set status. If your original mongod changes role from primary to another state those clients will be unable to write data: the server will return a "not master" error which will be mapped to an appropriate exception by your MongoDB driver.

For more information on expected behaviour for officially supported MongoDB drivers you may want to review the Server Discovery and Monitoring (SDAM) spec. In particular, the Rationale section addresses some implementation choices and common questions on topology discovery and monitoring.

Note for completeness: if you were upgrading to a sharded cluster you would definitely have to change your connection string. In a sharded cluster all client write operations should go via a mongos router.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.