Document Database Service

How to Connect to Database

2025-07-28 07:51:58

Intranet connection

  • Scenario: By default, the system provides a private IP address through which you can connect to the database.

    • If the application is deployed on an ECS that is in the same region, availability zone, or VPC subnet as the DDS instance, it is recommended to use intranet IP alone to connect to the DDS instance via ECS.

    • If DDS and ECS are in different security groups, they cannot be accessed by default. You need to add an "inbound" access rule to the security group to which the DDS belongs.

    • The default port for DDS is 8030, which needs to be manually modified to access other ports.

  • Connect to single node:

  mongodb://<username>:<password>@<instance_ip>:<instance_port>/<database_name>?authSource=admin&ssl=true
  • Connect to replica set:

  mongodb://<username>:<password>@<instance_ip>:<instance_port>/<database_name>?authSource=admin&replicaSet=replica&ssl=true
  • Connect to cluster:

  mongodb://<username>:<password>@<instance_ip>:<instance_port>/<database_name>?authSource=admin&ssl=true

Internet connection

  • Scenario: Access by binding a public EIP to the database.

    • If the application is deployed on an ECS that is in a different region from the DDS instance, it is recommended to use the public EIP alone to connect to the DDS instance via ECS.

    • If the application is deployed on another cloud service system, it is recommended to use the public EIP alone to connect to the DDS instance via ECS.

  • Connection method: Refer to the intranet connection section above.

Application Connection




8nPRzObFD3tp