All Products
Search
Document Center

ApsaraDB for MongoDB:Modify a whitelist

Last Updated:Jul 17, 2026

To ensure security and stability, ApsaraDB for MongoDB restricts access by default. The default whitelist contains only 127.0.0.1. Before using an instance, you must configure its whitelist to allow external connections. A properly configured whitelist enhances your instance's security. We recommend that you maintain your whitelist regularly.

Background information

  • Before you use an instance for the first time, you must add a whitelist group.

  • After you configure a whitelist, the instance's endpoint appears on the Basic Information and Database Connections pages.

Procedure

  1. Log on to the ApsaraDB for MongoDB console.

  2. Based on the instance type, click Replica Set Instances or Sharded Cluster Instances in the navigation pane on the left.

  3. In the upper-left corner of the page, select the instance's resource group and region.

  4. Click the target instance's ID, or click Manage in its Actions column.

  5. In the left navigation pane on the instance details page, click Data Security > Whitelist Settings.

  6. In the Whitelist Settings section, use one of the following methods to modify the whitelist for the instance.

    Modify manually

    1. Perform one of the following operations based on the instance type:

      • For a replica set instance: In the Actions column of the target group, click Modify.

      • For a sharded cluster instance: In the Actions column of the target group, click Manually Modify.

    2. In the Manually Modify panel, enter IP addresses or IP address ranges in the IP White List text box.

      • The following formats are supported:

        • A single IP address. Example: 10.23.12.24.

        • 0.0.0.0/0

          Warning

          Setting the whitelist to 0.0.0.0/0 allows access from any IP address. This creates a high security risk for your ApsaraDB for MongoDB instance. Use this value with caution.

        • CIDR format, which stands for Classless Inter-Domain Routing. For example, in 10.23.12.24/24, /24 indicates the prefix length of the address. The prefix length can be an integer from 1 to 32.

      • Separate multiple IP addresses or IP address ranges with commas (,).

    3. Click Confirm.

    Add ECS private IPs

    1. In the Actions column of the target group, click Add Internal IP Addresses of ECS Instances.

    2. In the Import ECS Intranet IP panel, select the private IP addresses of the ECS instances that you want to add from the IP Whitelist list.

    3. Click 添加.

    4. Click OK.

FAQ

Why can't I connect to my instance even after adding my public IP address to the allowlist?

This issue can occur if you added an incorrect public IP address to the allowlist. Follow these steps to find the correct public IP address of your local client:

  1. Add the IP address 0.0.0.0/0 to the allowlist of the MongoDB instance.

    Warning

    0.0.0.0/0 allows any device to access the MongoDB instance. This poses a security risk and must be used with caution. If you use this entry, you must promptly remove it from the allowlist.

  2. Use MongoDB Shell (mongosh) to connect to the instance.

    If you still cannot connect to MongoDB after setting the allowlist to 0.0.0.0/0, you can connect to MongoDB by using Data Management (DMS) to check whether the username, password, and authentication database are correct.

  3. Run the following command to query the client information for your MongoDB Shell (mongosh) session.

    db.currentOp({"appName" : "MongoDB Shell","active" : true})

    Example output:客户端IP查询

    Note

    If you connect to the instance using a different client, run the following command to query information for all active clients.

    db.runCommand({currentOp: 1, "active" : true})
  4. Add the obtained IP address to the MongoDB instance allowlist, and remove the IP address 0.0.0.0/0.

Why can't I connect to the instance even if the whitelist is configured correctly?

Check whether you are using the correct network type and endpoint. ApsaraDB for MongoDB supports connections over a private network and the public network. You must use the endpoint for your network type.

For more troubleshooting solutions, see Connection and network issues.

How do I configure a whitelist if the client IP address changes dynamically?

If your client has a dynamic IP address, you can connect to your ApsaraDB for MongoDB instance from a local client through an SSL-VPN tunnel or add the IP address range of your client to the whitelist.

Important

When you add a client's IP address range to the whitelist, narrow the range as much as possible to reduce security risks.