Why replica set is mandatory for transactions in MongoDB?

As per MongoDB documentation, transactions only works for replica sets and not single node. Why such requirement? Isn’t it is easier to do transaction stuff on a single node rather than a distributed system?


Hi @Rajat_Goel,

Since transactions are built on concepts of logical sessions they require mecahnics (like oplog) which are only available in replica set environment.

You can always convert a standalone to a single noded replica set and transactions will work with this one node.



Hello, Are there plans of mongo team to enable transactions for standalone servers in a next version of MongoDB? That would be great.

1 Like

Hi Iván,

Welcome to the community.

You can convert a standalone to a single-node replica set to enable transactions. All you have to do is start mongod with --replset flag.

The link posted by Pavel above goes into more detail.


Hello Mahi, yes I got it, however, I wonder if this feature will be available in a future (out of the box) for standalone servers? (in order to avoid that process of conversion :slight_smile: )