All Products
Search
Document Center

Why am I unable to connect to an ApsaraDB for MongoDB instance through DMS or the mongo shell

Last Updated: Jun 05, 2020

Note: This topic is a quick release topic provided by the Alibaba Cloud after-sales support team for specific or urgent issues. The content of this topic is presented as a draft and is not edited or reviewed. Therefore, Alibaba Cloud does not have any commitment to the content of this topic. We have the right to edit, modify, or provide additional information about the content of this topic without prior notice.

Symptom

One of the following error messages appears when you connect to an ApsaraDB for MongoDB instance through Data Management Service (DMS) or the mongo shell:

  • InvalidInstanceId.NotFound: The instance not in current vpc RequestId:xxxxxxxxxxx.
  • Authentication failed. The username, password, or instance name that you specify is incorrect.
  • An error occurred while connecting DMS with the MongoDB server. Make sure that you have entered the correct endpoint and the network connection is available. Check the IP address whitelist of the instance and try again.

Possible causes

  • The IP addresses of DMS servers are not in the IP address whitelist of the ApsaraDB for MongoDB instance.
  • The username, password, or instance name that you specify is incorrect.
  • The endpoint that you specify is incorrect, the network connection is unavailable, or the IP address whitelist is not properly configured.

Workaround

  • If you are using DMS, check whether the following configurations are correct:
  • The instance type and network type of the ApsaraDB for MongoDB instance
  • The instance name, and the username and password used to log on to the instance
  • The IP address whitelist of the instance

Procedure:

  1. Check whether the instance type and network type of the ApsaraDB for MongoDB instance are valid in DMS.

You can use DMS to log on to a replica set instance deployed in a Virtual Private Cloud (VPC) or an instance deployed on a classic network, but not a sharded cluster instance deployed in a VPC.

  1. Check whether the instance name, and the username and password used to log on to the instance are correct.
  2. Submit a ticket to check whether the IP addresses of DMS servers are in the IP address whitelist of the instance.
  • If you are using the mongo shell, check whether the following configurations are correct:
  • The version of the mongo shell: Check whether it matches the version of the ApsaraDB for MongoDB instance.
  • The region and network type of the ApsaraDB for MongoDB instance and Elastic Compute Service (ECS) instance
  • The endpoint and name of the ApsaraDB for MongoDB instance, and the username and password used to log on to the instance
  • The IP address whitelist of the instance

Procedure:

  1. Check whether the ECS instance and ApsaraDB for MongoDB instance are deployed in the same region and configured with the same network type.

If you want to connect to an ApsaraDB for MongoDB instance from an ECS instance over an internal network, the two instances must be deployed in the same region and configured with the same network type. If the network type is set to VPC, the two instances must be deployed in the same VPC.

  1. Check whether the endpoint and name of the ApsaraDB for MongoDB instance, and the username and password used to log on to the instance are correct.
  2. Check whether the internal IP addresses of the ECS instance are in the IP address whitelist of the ApsaraDB for MongoDB instance.
  3. Run the ping and telnet commands on the ECS instance to check whether the ApsaraDB for MongoDB instance is connected. If the connection fails, check whether any access restriction is set on the ECS security group and firewall.
  4. Submit a ticket if the configurations are correct but the connection still fails.

References

Replica set instance

Connect to a replica set ApsaraDB for MongoDB instance through DMS
Connect to a replica set instance by using the mongo shell

Sharded cluster instance

Connect to a sharded cluster ApsaraDB for MongoDB instance through DMS
Connect to a sharded cluster instance by using the mongo shell
Causes of and solutions to common logon and database registration failures in DMS