If a client cannot connect to an ApsaraDB for MongoDB instance, you can use the connection diagnosis feature to verify that the client's IP address is in the instance's whitelist.
Limitations
ApsaraDB for MongoDB supports connection diagnosis only for standalone and replica set instances.
Procedure
-
Go to the MongoDB replica set instances page, select the resource group and region at the top of the page, and then click the ID of the target instance.
-
On the Basic information page, in the Connection information section, click Connection diagnosis on the right.
-
In the Connection diagnosis panel, enter an IP address based on the scenarios in the following table.
Connection scenario
Description
An ECS instance connects to an ApsaraDB for MongoDB instance in the same region.
You can access the instance over a VPC (private network) or the public network.
-
Set Client type to Select ECS instance.
-
Select an ECS instance ID (only instances in the same region are supported):
-
If the ECS instance ID is green, the ECS instance and the ApsaraDB for MongoDB instance are in the same VPC. You can access the MongoDB instance over the VPC or the public network.
-
If the ECS instance ID is red, the ECS instance and the ApsaraDB for MongoDB instance are not in the same VPC. You can access the MongoDB instance only over the public network.
-
-
Select the ECS IP address to be used for access.
-
An ECS instance in a different region connects to an ApsaraDB for MongoDB instance.
For example, the ECS instance is in the China (Beijing) region and the ApsaraDB for MongoDB instance is in the China (Hangzhou) region.
-
A local device connects to an ApsaraDB for MongoDB instance.
You can access the instance only over the public network.
-
Set Client type to Enter IP address.
-
Enter the client's IP address.
-
-
Click Start diagnosis.
-
Review the diagnosis result.
-
Check failed: This result indicates that the specified IP address is not in the whitelist of the ApsaraDB for MongoDB instance. You can click Add now and follow the on-screen instructions to add the IP address to the default group in the instance's whitelist, and then run the diagnosis again.
Alternatively, click Whitelist settings to go to the Whitelist settings page and manually add the IP address to the whitelist.
-
Check passed: This result indicates that the specified IP address is already in the whitelist of the ApsaraDB for MongoDB instance.
After the diagnosis is complete, use the verified IP address to connect to the ApsaraDB for MongoDB instance from your client.
NoteThis feature only verifies that the client's IP address is in the ApsaraDB for MongoDB instance whitelist. If the check passes but you still cannot connect to the instance, the connection failure may have one of the following causes:
-
Network issues: Run the
pingcommand to test the network connection between the client and the ApsaraDB for MongoDB instance. If a network error occurs, check your client's network environment. -
Dynamic client IP address: If the client's public IP address is dynamic, the connection fails when the address changes. In this case, you can assign a static IP address to the client or add
0.0.0.0/0to the instance's whitelist.The
0.0.0.0/0entry allows any device to access the ApsaraDB for MongoDB instance. Use this entry with caution. -
Incorrect password: Verify the database account password for the ApsaraDB for MongoDB instance.
-