All Products
Search
Document Center

ApsaraDB for MongoDB:Change the endpoint and port of an instance

Last Updated:Aug 24, 2026

ApsaraDB for MongoDB allows you to change the internal or public endpoint and the port of an instance.

Limits

The following table describes the limits on changing the endpoint and port of an ApsaraDB for MongoDB instance, and the scenarios for switching to a new instance.

instance typeEndpointPortScenario for switching to a new instance
Standalone instanceA standalone instance has only one primary node. You can change the endpoint of the primary node.You cannot change the port of a standalone instance.You can change the endpoint and port of the new instance to the endpoint and port of the original instance. In this case, you do not need to change the endpoint and port in your application.
Replica set instanceYou can change the endpoints of primary, secondary, and read-only nodes on both local SSD instances and ESSD instances.You can change the port of ESSD instances that run MongoDB 4.2 or later.The connection string of the replica set high-availability endpoint contains replicaSet information, which cannot be changed. Therefore, after you switch to a new instance, you must change the endpoint and port in your application.
Sharded cluster instanceIf the instance uses the MongoDB protocol, you can change the endpoints of mongos nodes only. If the instance uses the DynamoDB-compatible protocol, you can change the endpoint of the config server node.You can change the port of ESSD instances that run MongoDB 4.2 or later.You can change the endpoint and port of the new instance to the endpoint and port of the original instance. In this case, you do not need to change the endpoint and port in your application.

Prerequisites

  • (Required only to change a public endpoint) A public endpoint is applied for the instance. The Public Connections section displays the Update Connection String button only after you apply for a public endpoint. For more information, see Apply for a public endpoint.

Procedure

  1. Go to the Replica Set Instances or Sharded Cluster Instances page. In the top navigation bar, select the resource group and region to which the desired instance belongs. Then, find the instance and click the instance ID.

  2. In the left-side navigation pane of the instance details page, click Database Connections.

  3. In the Internal Connections - VPC section or the Public Connections section, click Update Connection String. Select the section based on whether you want to change the internal endpoint or the public endpoint of the instance.

  4. In the Update Connection String panel, configure the following parameters.

    ParameterDescription
    Node

    From the drop-down list, select the node whose endpoint you want to change.

    Note

    For sharded cluster instances, you can change the endpoints of mongos nodes only.

    Current Connection StringThe current connection string of the node whose endpoint you want to change. This parameter is read-only.
    New Connection StringEnter the prefix of the new endpoint based on the following rules: The prefix must start with a lowercase letter. The prefix must end with a lowercase letter or a digit. The prefix can contain lowercase letters, digits, and hyphens (-), and must be 8 to 64 characters in length.
    Port NumberThe port number of the new endpoint. Valid values: 1,000 to 65,535.
  5. Click OK.

What to do next

After you change the endpoint, change the endpoint and port in your application to the new endpoint and port.