If an Elastic Compute Service (ECS) instance is in the classic network and an ApsaraDB for MongoDB instance is in a virtual private cloud (VPC), or if the ApsaraDB for MongoDB instance is in the classic network and the ECS instance is in a VPC, you can use the methods described in this topic to connect the ECS instance to the ApsaraDB for MongoDB instance.

Prerequisites

Connection methods

ECS instance network type ApsaraDB for MongoDB instance network type Connection method
Classic network VPC
  • Migrate the ECS instance to the VPC to which the ApsaraDB for MongoDB instance belongs. For more information, see Migrate an ECS instance from a classic network to a VPC.
  • Use ClassicLink. For more information, see Connect a classic network to a VPC.
    Note
    • Before you create a ClassicLink connection, make sure that you understand the limits of ClassicLink. For more information, see Overview.
    • The ClassicLink-based interconnection is a temporary solution in specific conditions. To achieve high-speed connection in the production environment, we recommend that you create the ECS and ApsaraDB for MongoDB instances in the same VPC.
VPC Classic network
Note ApsaraDB for MongoDB replica set and sharded cluster instances that are purchased on and after February 21, 2022 do not support classic network and can only use VPC. For more information, see Notice on classic network unavailability for new ApsaraDB for MongoDB instances.
Migrate the ApsaraDB for MongoDB instance to the VPC to which the ECS instance belongs. For more information, see Switch the network type of an ApsaraDB for MongoDB instance from classic network to VPC.
Note
  • You cannot change the network type of standalone instances.
  • Switching network types will cause a transient connection for the ApsaraDB for MongoDB instance. To prevent negative impacts on your business, we recommend that you perform this operation during off-peak hours or ensure that your application has a reconnection mechanism.