This article describes how to troubleshoot the failure to connect to an RDS instance.
You can troubleshoot the issue from the following five aspects:
- Check the instance status and instance connection information
- (Common) check whether the whitelist is correctly configured
- (Common) check the database performance
- (Common) check clients
- You cannot access an RDS instance from an ECS instance through the intranet
Step 1: Check the instance status and instance connection information
- Log on to the apsaradb for RDS console. View the status of the instance in the instance list and confirm the instance status is normal. Troubleshoot issues such as abnormal instance status or being locked. If the instance is locked, see troubleshooting methods for automatic locking of MySQL instances when the instance space is full. While the instance is locked, the application cannot perform read or write operations on the RDS Database. If your business permits, you can try to restart the instance. Proceed with caution.
- In the code or tool for connecting to the database, check whether the information for connecting to the database is correct (confirm the intranet and internet address). For more information, see how to connect to RDS Database.
Step 2: Check whether the whitelist is correctly configured
Make sure that you have added the correct local Device IP address to the IP whitelist of the RDS instance. Temporarily add a
0.0.0.0/0 to the whitelist of the database. If the database can be accessed normally after setting the whitelist, it indicates that a problem exists with the whitelist settings. Remove the
0.0.0.0/0 whitelist the right add the IP addresses of the ECS Security Group whitelist takes effect immediately in The. For more information about whitelist considerations, see the following content. For more information about how to add a whitelist, see set whitelist.
- Since the
127.0.0.1. The default IP address 127.0.0.1 indicates that no devices can access your RDS instance. Therefore, you need to add the IP address of the peer ECS instance to the whitelist.
in only the default address
- The whitelist is set to
0.0.0.0. The valid format is
0.0.0.0/0indicates that any device is allowed to access the RDS instance. Use it with caution.
- Check whether you have enabled the enhanced whitelist mode. For more information, see enhanced whitelist mode. If enabled, perform the following checks:
- If your RDS instance resides in a VPC and is accessed by using its internal endpoint, make sure that the internal IP address of your ECS instance is added to the IP address whitelist labeled default VPC.
- If your RDS instance resides in the classic network and is accessed by using its internal endpoint, make sure that the internal IP address of your ECS instance is added to the IP address whitelist labeled default Classic Network.
- If your RDS instance resides in the classic network and is accessed over the Internet, make sure that the public IP address of your ECS instance is added to the IP address whitelist labeled default Classic Network.
- The public IP addresses that you add to the whitelist are invalid. The reasons are:
- The public IP addresses dynamically change.
- The tools or websites used to query public IP addresses provide incorrect IP addresses. For more information about the solutions, see the following topics:
Step 3: Check database performance
You can view the performance monitoring information of an RDS instance to determine whether its resources are insufficient.
- Check the number of connections to the current database.
- The full number of connections is usually due to too many idle connections or active connections. See primary instance specification list to confirm the maximum connection data corresponding to the instance specification.
- Check whether the connection settings in the code are reasonable and whether most connections are not closed in time, thus consuming RDS resources and finally causing the number of connections to be full. For the causes of and solutions to this problem, see handling the case of full connections on RDS for MySQL or handling the case of full connections on RDS for PostgreSQL.
- If the business increases normally, we recommend that you upgrade the instance configuration.
note: there may be a transient disconnection of about 30s during the upgrading process. We recommend that the user do a good job of reconnection mechanism to ensure the normal operation of the user's business. For more information, see RDS usage instructions.
- Check whether the network traffic is normal and whether there is a high network traffic occupation. If this happens, see view slow log details to view slow logs and optimize slow SQL statements based on the query results.
- For other performance issues, see resolve high CPU, memory, space, and IOPS usage.
Step 4: Check the client
You can try other ways to connect to the database and confirm if it is the problem of the current client tool. For more information, see connect to MySQL instance.
You cannot access an RDS instance from an ECS instance through the intranet
If the ECS instance cannot access the RDS instance through the intranet, you can see solve the problem of unable to connect to the RDS instance to solve the problem.