You can use the mongo shell to connect to an ApsaraDB for MongoDB instance.


Use mongo shell 3.0 or a later version to connect to ApsaraDB for MongoDB, otherwise authentication fails.


  1. Log on to the ApsaraDB for MongoDB console.
  2. Click the target instance ID to go to its Basic Information page.
  3. In the left-side navigation pane, click Database Connection to view the connection information under Intranet Connection - VPC and Public IP Connection and select a connection type as required, as shown in the following figure.

    In each connection address, the domain name is separated from the port number with a colon (:). The default port number is 3717, and the default database name is admin.

  4. On an ECS instance, run a mongo command to connect to ApsaraDB for MongoDB. The following command is an example:
    mongo --host -u root -p --authenticationDatabase admin

    Mongo shell FAQs