You need to enable JavaScript to run this app.
Document Database for MongoDB

Document Database for MongoDB

Copy page
Download PDF
Network and connection management
Modifying port
Copy page
Download PDF
Modifying port
The Document Database for MongoDB supports modifying the port number of the connection address of replica set instances and Mongos nodes in the sharding cluster instances. This topic describes how to modify the port number of the connection address.​
Prerequisite​
The instance status must be Running. For more details, refer to Instance status.​
Limits​
Currently, only the port number of the connection address of replica set instances and the Mongos nodes in sharding cluster instances can be modified. The port numbers of Shard or ConfigServer nodes in sharding cluster instances cannot be modified. For more information on the connection addresses supported by each instance or component type, refer to Connection addresses supported by different instances.​
Precautions​
  • Modifying the port number will cause access to some services to be affected in a short time. Please operate with caution.​
  • After modifying the port number, the original connection will be disconnected. Please modify the connection information of the client in a timely manner. For specific procedures, refer to Connecting to instance via Mongo shell.​
  • The effective scopes of new ports vary depending on the instance or component type. The specific effective scopes are shown in the following table. The specific effective scopes are shown in the following table.​
  • ​
    Instance or component type​
    Effective scope of new ports​
    Replica set instance​
    • After the port number is modified, it will take effect on the private network address ports of all existing primary, secondary, hidden, and read-only nodes on the instance.​
    • At the same time, it will also take effect on the public network address ports of all existing primary, secondary, and read-only nodes on the instance.​
    • After the port number is modified, when a new read-only node is added to the instance, the port of the new read-only node will also inherit the modified port number. For more information about read-only nodes, refer to Managing read-only nodes.​
    Mongos node in sharding cluster instance​
    • After the port number is modified, it will take effect on the public and private network address ports of all existing Mongos nodes on this instance.​
    • After modifying the port number, when a new Mongos node is added to the instance, the port of the newly added Mongos node will also inherit the modified port number.​
    ​
Procedure​
  1. Log in to the MongoDB console.​
  1. In the upper-left corner of the top menu bar, select the project and region for instance.​
  1. Select either Replica set instances or Sharding instances in the left navigation bar depending on the instance type.​
  1. On the target instance type list page, click the target instance name.​
  1. On the instance details page, click on the Connectivity tab.​
  1. In the Network information area under the Connectivity tab, after Database port click ​​ icon.​
  1. In the pop-up dialog box, enter a new port number. The modifiable range of port numbers is 1000 to 65535.​
danger​
  • Modifying the port number will cause access to some services to be affected in a short time. Please operate with caution.​
  • After modifying the port number, the original connection will be disconnected. Please modify the connection information of the client in a timely manner. For specific procedures, refer to Connecting to instance via Mongo shell.​
  1. Click OK.​
Relevant APIs​
​
API​
Description​
Call the ModifyDBEndpointPort interface to modify port number of connection address corresponding to target MongoDB instance.​
​
​
Last updated: 2026.02.12 21:43:25