All Products
Search
Document Center

ApsaraDB for MongoDB:Errors and exception handling

Last Updated:Jun 02, 2026

Lists common ApsaraDB for MongoDB error messages and exceptions with their causes and solutions.

Error message

Cause and solution

Specified parameter AccountDescription is not valid.

When restoring a backup to a new instance, ensure the new instance name meets the specified limits.

Shard total number is out of range.

When restoring a sharded cluster to a new instance, the new instance must have the same number of shards as the source.

Downgrading instance storage is not supported.

Storage capacity cannot be decreased. Create a new instance to replace the original. Other instance specification change scenarios.

Classic network is not supported. Try using VPC.

Classic network instances no longer support renewal, specification changes, or billing method changes. [Notice] Retirement of the classic network for ApsaraDB for MongoDB.

There are not enough resources for your operation.

The destination zone has insufficient resources. Try a different instance specification, or submit a ticket to contact technical support.

The oplog of the source database is not enabled.

Standalone instances have no oplog and do not support incremental migration with Data Transmission Service (DTS). Use full data migration instead.

The request references an incorrect order sales component. Contact customer support.

Resource availability varies by zone. Try a different zone or instance specification, or submit a ticket to contact technical support.

User request was denied due to user flow control.

Alibaba Cloud limits API call frequency. View your current quotas or request a quota increase in Quota Center.

Database config lacks read privileges.

When migrating data with Data Transmission Service (DTS), the source and destination database accounts must have the required permissions. Grant permissions as described in the following topics:

Specified restore time is not valid.

When you restore an instance by calling an API, ensure that the restore time is valid. The time must be in the yyyy-MM-ddTHH:mm:ssZ format and specified in Coordinated Universal Time (UTC). For example, a China Standard Time (UTC+8) of 20:00:00 on November 8, 2024, converts to 2024-11-08T12:00:00Z in UTC.

server returned error on SASL authentication step: BSON field 'saslContinue.mechanism' is an unknown field.

Cross-version restores may fail due to differing authentication mechanisms: SCRAM-SHA-1 (MongoDB 4.0) vs. SCRAM-SHA-256 (MongoDB 5.0+). Use an earlier mongorestore version (such as 4.0) when restoring across major versions.

TypeError: db.xxx.find is not a function.

The collection name may be a reserved keyword. Use db.getCollection("xxx").find to query the collection, or rename it.

createUser failed: Command failed with error xx (Unauthorized): 'not authorized on admin to execute command xxx'

Write permissions on the admin database are restricted to prevent performance jitter. You cannot create accounts with admin write access. What permissions does the root account that is specified during instance creation have?

Specified network type does not match.

If a classic network security group is already added to the instance, you cannot add a VPC security group at the same time.

The instance's minor version is not supported for this API.

The instance runs an outdated minor version. Upgrade the minor version of the database.

The instance is at the End of Full Support (EOFS) stage.

The instance has entered End of Full Support (EOFS) and cannot be renewed. Upgrade the major version of the database.

Resource unavailable.

A resource issue occurred during instance creation or modification. Obtain the Request ID and submit a ticket to contact technical support.

Connection and network errors

Error message

Cause and solution

network error while attempting to run command 'isMaster' on host 'dds-xxxx.mongodb.rds.aliyuncs.com:3717' :exception: connect failed

  • Timed out after 3000ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. exception=(com.mongodb.MongoSocketReadException: Prematurely reached end of stream)

  • Socket recv() errno:54 Connection reset by peer x.x.x.x:27017

The instance has likely reached its connection limit and is refusing new connections.

Solution:

  1. Check whether the connection limit is reached. For more information, see How do I query the number of connections?.

  2. Optimize connection usage. For more information, see What do I do if the number of connections to an instance reaches the upper limit?.

MongoDB.Driver.MongoWaitQueueFullException: The wait queue for acquiring a connection to server xxx is full.

The wait queue of the MongoDB driver is full. This can happen if the connection pool size is too small or if there is a high volume of concurrent requests, which exhausts available connections.

Solution:

  1. Check the connection pool configuration in your application. Make sure that the connection pool size is appropriate. For more information, see How do I limit the number of client connections?.

  2. If the issue persists after you adjust the application-side settings, check whether the ApsaraDB for MongoDB instance has reached its connection limit. For more information, see the following topics:

    1. How do I query the number of connections?

    2. What do I do if the number of connections to an instance reaches the upper limit?

(TooManyLogicalSessions) Unable to add session into the cache because the number of active sessions is too high.

An excessive number of concurrent connections can exhaust the available sessions.

Solution:

  1. Troubleshoot connection failures that are caused by an exhausted connection limit.

    1. How do I query the number of connections?

    2. What do I do if the number of connections to an instance reaches the upper limit?

  2. If the number of connections is normal, check whether other performance metrics of the instance are sufficient for your business requirements.

    1. Use node monitoring to view the usage of common resources, such as CPU and memory. This helps you determine whether the instance type meets your business requirements.

    2. If the instance type is too small for the workload, change the instance configuration during off-peak hours.

  • getaddrinfo failed.

  • No suitable servers found (`serverSelectionTryOnce` set).

Check whether the instance endpoint is correct. For more information, see the following topics:

  • Failed to connect to 10.*.*.8:3717 after 5000 milliseconds, giving up.Error: couldn't connect to server 10.*.*.8:3717 (10.*.*.8), connection attempt failed

  • pymongo.errors.ServerSelectionTimeoutError: dds-xxxx.mongodb.rds.aliyuncs.com:3717: [Errno 113] No route to host,dds-xxxx.mongodb.rds.aliyuncs.com:3717

  • InvalidInstanceId.NotFound: The instance not in current vpc.

An ECS instance fails to connect to an ApsaraDB for MongoDB instance over a private network.

Solution:

  1. Check the whitelist settings. Make sure that the private IP address of the ECS instance is added to the whitelist of the ApsaraDB for MongoDB instance.

  2. Make sure that the ECS instance and the ApsaraDB for MongoDB instance can communicate with each other.

    If the ECS instance and the ApsaraDB for MongoDB instance are in the same VPC, they can connect directly over the private network. For cross-VPC connections, use one of the following methods:

org.springframework.data.mongodb.UncategorizedMongoDbException: Timeout while receiving message; nested exception is com.mongodb.MongoSocketReadTimeoutException: Timeout while receiving message

  • "errmsg": "not master", "code": 10107, "codeName": "NotMaster"

  • "errmsg": "not master", "code": 10107, "codeName": "NotWritablePrimary"

  • Time out after 30000ms while waiting for a server that matches writableServerSelector.

  • Command failed with error 10107 (NotWritablePrimary): 'not primary' on server xxx.

  • Explain's child command cannot run on this node. Are you explaining a write command on a secondary?

  • not master and slaveOk=false.

  • MongoNotPrimaryException: Command failed with error 10107 (NotMaster): 'not master' on server xxx.

  • reason: TopologyDescription { type: 'ReplicaSetNoPrimary',...}

The node that you are writing data to is not the primary node.

Cause: Write operations can be performed only on the primary node. A failover can change a primary node (to which your application was connected) into a secondary node, causing subsequent write operations to fail.

Solution:

As a best practice, implement reconnection logic and exception handling in your application. This ensures that your application can automatically reconnect after a transient disconnection and remain stable.

[Unauthorized] cloud instance error, disk locked, plz check and upgrade your disk quota,

The instance is locked because its disk space is full.

Solution: See Resolve instance locking or write failures caused by exhausted disk space.

(AuthenticationFailed) Authentication failed.

  • !xxx@dds-xxx.mongodb.rds.aliyuncs.com: event not found

The password of the database account contains special characters, such as !@#$%^&*()_+=.

Solution: See How do I resolve a connection failure that is caused by special characters in a password?.

error getting cluster ID: (CommandNotFound) replSetGetConfig is forbidden by cloud provider for security reason

ApsaraDB for MongoDB does not support the replSetGetConfig command. For more information, see Supported and unsupported commands in ApsaraDB for MongoDB.

Upgrade errors from 4.2 to 4.4

Error message

Cause and solution

CHECK_USER_COLLECTIONS_IN_ADMIN_FAILED

Cause: The admin database contains non-system collections. MongoDB 4.4+ revokes write permissions on the admin database for root and custom accounts. Move these collections to other databases.

Solution:

  1. Run the following command to move the old_collection collection to the new_collection collection in new_db. The old and new collection names can be the same.

    db.getSiblingDB("admin").runCommand({renameCollection: "<admin.old_collection>", to: "<new_db.new_collection>"})
    Important

    For large collections, this command blocks all writes until complete. Schedule sufficient maintenance time.

  2. After the rename operation is complete, run the drop command to delete the original collection. You can then upgrade the instance to version 4.4.

    db.getSiblingDB("admin").getCollection("<old_collection>").drop()

CHECK_USERS_AND_ROLES_FAILED

Cause: The admin database has custom accounts with high-privilege roles. MongoDB 4.4+ revokes write permissions on the admin database for root and custom accounts. Remove these write permissions from the custom accounts.

Solution: The console error message identifies the account and role: "user my_user has high privilege role readWrite". Run the following command to revoke the readWrite role on the admin database from my_user.

Important

Before running this command, ensure your application does not use this account to write data to the admin database.

db.getSiblingDB("admin").runCommand({revokeRolesFromUser: "my_user", roles: [{role: "readWrite", db: "admin"}]})