Help Center> Relational Database Service> FAQs> Database Connection> What Should I Do If an ECS Cannot Connect to an RDS DB Instance?

What Should I Do If an ECS Cannot Connect to an RDS DB Instance?

Perform the following steps to identify the problem:

  1. Check whether the ECS and RDS DB instance are located in the same VPC.

    • If they are in the same VPC, go to 2.
    • If they are in different VPCs, create an ECS in the VPC in which the RDS DB instance is located.

  2. Check whether a security group has been added to the ECS.

    • If a security group has been added, check whether its configuration rules are suitable.

      For MySQL DB instances, see the security group description in Buying an RDS MySQL DB Instance. Then, go to 3.

      For PostgreSQL DB instances, see the security group description in Buying an RDS PostgreSQL DB Instance. Then, go to 3.

      For Microsoft SQL Server DB instances, see the security group description in Buying an RDS Microsoft SQL Server DB Instance. Then, go to 3.

    • If no security group has been added, go to the VPC console from the ECS details page and click Security Groups to add a security group.

  3. On the ECS, check whether the RDS DB instance port can be connected.

    The default port of RDS for MySQL is 3306.

    The default port of RDS for PostgreSQL is 5432.

    The default RDS for Microsoft SQL Server port number is 1433.

    telnet <IP address> {port number}
    • If the ECS can connect to the RDS DB instance port, the network between the ECS and the RDS DB instance is normal.
    • If the ECS cannot connect to the port, contact technical support.

  4. If you originally use the common connection and later change the SSL connection for security reasons, you should use the SSL login. Otherwise, the following error will be reported:

    mysql: [Warning] Using a password on the command line interface can be insecure.

    ERROR 2026 (HY000): SSL connection error: protocol version mismatch

    Check whether the connection mode is a common connection or an SSL connection.

    If you use the SSL connection, check whether the SSL connection is enabled.

    For details about a common connection and an SSL connection, see Connecting to a DB Instance.