Problem description
When you log on to a MongoDB database from a Linux instance by using the Mongo Shell, the following error message is displayed.
MongoDB shell version: 3.2.3
DB Prefix:
connecting to: 10.X.X.8:3717/admin
2016-05-31T15:25:58.940+0800 W NETWORK Failed to connect to 10. *. *.8:3717 after 5000 milliseconds, giving up.
2016-05-31T15:25:58.943+0800 E QUERY Error: couldn't connect to server 10. *. *.8:3717 (10.X.X.8), connection attempt failed
at connect (src/mongo/shell/mongo.js:181:14)
at (connect):1:6 at src/mongo/shell/mongo.js:181
exception: connect failed
Cause
POSSIBLE CAUSES:
The Linux instance and the apsaradb for MongoDB instance do not belong to the same VPC.
The network types of the Linux instance and the apsaradb for MongoDB instance are different.
Solution
Choose one of the following methods to fix the issue based on-site conditions:
Change the network type of the apsaradb for MongoDB instance to classic network and then switch back to VPC.
NoteInstructions select the same VPC as the Linux instance.
The network types of a Linux instance and an apsaradb for MongoDB instance are different. For more information, see how to connect an ECS instance to an apsaradb for MongoDB instance when their network types are different.
Log on to the Linux instance and run the following command to check whether the network connection between the Linux instance and the apsaradb for MongoDB instance is normal:
telnet dds-ali12XXXXX.mongodb.rds.aliyuncs.com 3717
NoteInstructions the port of an apsaradb for MongoDB instance is 3717.
A similar output is displayed. Confirm that the domain name is resolved and that Port 3717 can communicate properly.
Documentation
Application scope
ApsaraDB for MongoDB