Docs Menu

Docs HomeMongoDB Manual

Compatibility Changes in MongoDB 5.1

On this page

  • Removed Operators
  • Removed Parameters
  • $setWindowFields Stage with Transactions and Snapshot Read Concern
  • Replica Sets
  • Time Series Collections
  • General Changes
  • Platform Support


MongoDB 5.1 is a rapid release and is only supported for MongoDB Atlas. MongoDB 5.1 is not supported for use on-premises. For more information, see MongoDB Versioning.

The following 5.1 changes can affect compatibility with older versions of MongoDB.

Starting in MongoDB 5.1, these operators are removed:

Removed Operator
See Legacy Opcodes Removed

MongoDB 5.1 removes the following server parameters:

Removed Parameters

This option is removed from the MongoDB Community Edition. It is available in MongoDB Enterprise edition.

FIPS was not a supported feature in MongoDB Community Edition. If your installation made use of FIPS anyway, you will need to reconfigure your TLS/SSL connections before upgrading.

MongoDB 5.1 removes the following parameters from the mongo shell:

Removed Parameters
The ability to use OP_INSERT, OP_UPDATE, and OP_DELETE is removed. The shell will only use OP_MSG write commands.
The ability to use OP_INSERT, OP_UPDATE, and OP_DELETE is removed. The shell will only use OP_MSG write commands.
The ability to use OP_QUERY legacy find is removed. The shell will only use OP_MSG find commands.
Support for the OP_QUERY RPC protocol is removed. The shell will always use the OP_MSG RPC protocol.

In MongoDB versions earlier than 5.3, the $setWindowFields aggregation pipeline stage cannot be used with transactions or the "snapshot" read concern.

Starting in MongoDB 5.1, when starting, restarting or adding a shard server with sh.addShard() the Cluster Wide Write Concern (CWWC) must be set.

If the CWWC is not set and the shard is configured such that the default write concern is { w : 1 } the shard server will fail to start or be added and returns an error.

See default write concern calculations for details on how the default write concern is calculated.

Starting in MongoDB 5.1, you must set the Cluster Wide Write Concern (CWWC) prior to issuing any reconfigs that would otherwise change the default write concern of the new replica set member.

Arbiters are not supported with quarterly rapid releases. If your deployment includes arbiters, only use LTS releases.


If you create a sharded time series collection in MongoDB 5.1 or greater, downgrading to a version older than MongoDB 5.0.4 will result in data loss.

Before downgrading to a version older than 5.0.4, drop all sharded time series collections.

Starting in MongoDB 5.1, invalid $regex options options are no longer ignored. This change makes $regex options more consistent with the use of $regex in the aggregate command and projection queries.

Starting in MongoDB 5.1, if a collection has schema validation rules that contain invalid $regex options the server:

  • Prevents all insert and update operations until the schema validation rules containing the invalid regex pattern are modified with the collMod command.

  • Writes a warning error to the mongod log file.

Starting in MongoDB 5.1, instances running in FIPS mode have the SCRAM-SHA-1 authentication mechanism disabled by default. You can enable the SCRAM-SHA-1 authentication mechanism with the setParameter.authenticationMechanisms command.

This change will not affect drivers which target MongoDB setFeatureCompatibilityVersion 4.0+.

Starting in MongoDB 5.1 (and 5.0.4 and 4.4.10), the $mod operator returns an error if the divisor or remainder values evaluate to certain values. See $mod behavior.

MongoDB drivers have used OP_MSG instead of OP_QUERY and the other legacy opcodes since MongoDB v3.6.

This release removes support for the following legacy opcodes:

To avoid disruption due to the removal of these op codes, please upgrade your driver to the latest version.

mongod will close the connection and will not respond to:

mongod will return an error for:

The OP_QUERY RPC protocol may be used with the following commands:

  • _isSelf

  • authenticate

  • buildinfo

  • buildInfo

  • hello

  • ismaster

  • isMaster

  • saslContinue

  • saslStart

OP_QUERY will return an error if it is used for a find operation. All other commands will be rejected if issued as OP_QUERY.

If you attempt to connect to a MongoDB 3.4, or older, mongod instance with a MongoDB 5.1, or newer, mongo shell, you will receive an error message like the following:

Connection handshake failed. Is your mongod 3.4 or older?
:: caused by :: network error while attempting to run command
'isMaster' on host ''

Starting in MongoDB 5.1.2 the following platforms are no longer supported.

  • RHEL-72-s390x

What is MongoDB? →