What Should I Do If I Can't Connect to My RDS DB Instance?
Possible Causes
Try the following:
- Check whether the DB instance is available.
For example, the system is faulty, the DB instance is abnormal, or the DB instance or a table is locked.
- (Common) Check whether the client connection is correct.
- If you connect to a DB instance over a private network, ensure that the DB instance and ECS are in the same region and VPC.
- If you connect to a DB instance over a public network, bind an EIP to the DB instance and then connect to the DB instance through the EIP.
- Check the connection method.
Run either of the following example commands to enable or disable SSL:
- SSL enabled: mysql -h 172.16.0.31 -P 3306 -u root -p --ssl-ca=/tmp/ca.pem
- SSL disabled: mysql -h 172.16.0.31 -P 3306 -u root -p
- Check whether the parameters in the connection command are correct.
For example, check whether the following parameters are configured correctly: connection address, port number, username, password, and connection method.
- (Common) Check whether the network connectivity is normal
For a private network connection:
- Check whether the ECS and DB instance are in the same region and VPC.
- Check security group rules.
To access DB instances in a different security group from the ECS, add an inbound rule for the security group.
- On the ECS, check whether the DB instance port can be connected to.
For a public network connection:
- Check security group rules.
To access DB instances in a security group from a public network, add an inbound rule for the security group.
- Check network ACL rules.
- Ping the ECSs in the same region to the DB instance.
- (Common) Check whether the number of connections to the DB instance reaches the upper limit.
If there is an excessive number of database connections, applications may be unable to connect.
- (Common) Check whether the DB instance is in the Storage full state.
If the DB instance is in the Storage full state, data read and write performance is affected.
Fault Locating
- Check whether the DB instance is available.
Check whether the DB instance is in the Available state.
Possible cause: The RDS system is faulty, the DB instance is abnormal, or the DB instance or a table is locked.
Solution: If the DB instance is abnormal, reboot it.
- Check whether the client connection is correct.
Install an engine client whose version is at least as new as the DB instance version.
For details about how to connect to a DB instance over a private or public network, see Can an External Server Access the RDS Database?
Table 1 Connection model Connection method
Scenario
Example
Private network
A private IP address is provided by default.
If your applications are deployed on an ECS that is in the same region and VPC as the DB instance, connect to the ECS and DB instance through a private IP address.
RDS for MySQL:
mysql -h <private IP address> -P 3306 -u root -p --ssl-ca=/tmp/ca.pem
Public network
If you cannot access the DB instance using a private IP address, bind an EIP to the DB instance and then connect to the DB instance through the EIP.
RDS for MySQL:
mysql -h <EIP> -P 3306 -u root -p --ssl-ca=/tmp/ca.pem
- Check the connection method.
- SSL connection is recommended. Enable SSL on the Connectivity & Security page and upload the certificate to the ECS.
mysql -h 172.16.0.31 -P 3306 -u root -p --ssl-ca=/tmp/ca.pem
- Common connection: Disable SSL on the Basic Information page.
mysql -h 172.16.0.31 -P 3306 -u root -p
- SSL connection is recommended. Enable SSL on the Connectivity & Security page and upload the certificate to the ECS.
- Check the parameters in the command used to connect.
Ensure that the connection address, port, username and password, and SSL connection method are correct, and try to connect to the DB instance again.
If you use a private connection with SSL enabled, run mysql -h 172.16.0.31 -P 3306 -u root -p --ssl-ca=/tmp/ca.pem.
- IP address
On the Private Connection tab of the Connectivity & Security page, obtain the floating IP address in the Connection Information area.
- Database Port
On the Private Connection tab of the Connectivity & Security page, obtain the database port in the Connection Information area.
- Root login credentials
- Certificate
Obtain the SSL certificate name from the directory where the command is executed.
If you use a public connection with SSL enabled, run the following example command: mysql -h EIP -P 3306 -u root -p --ssl-ca=/tmp/ca.pem
- IP address
On the Public Connection tab of the Connectivity & Security page, obtain the EIP in the Connection Information area.
- Database Port
On the Public Connection tab of the Connectivity & Security page, obtain the database port in the Connection Information area.
- Root login credentials
- Certificate
Obtain the SSL certificate name from the directory where the command is executed.
- IP address
- Check the network connection.
Private network connection
Public network connection
- Check whether there are too many connections to the DB instance.
Check method:
- Run show variables like '%max%connections%'; to view the number of instance connections.
- max_connections: the maximum number of clients that can be connected at the same time. If this parameter is set to default, the maximum number of clients depends on the amount of memory configured. For details, see What Is the Maximum Number of Connections to an RDS DB Instance?.
- max_user_connections: the maximum number of concurrent connections allowed for a specific RDS for MySQL account.
- Check whether the total connections and current active connections have reached the upper limits by referring to Viewing Monitoring Metrics. Determine whether to release the connections.
Possible cause: If there are too many database connections, applications may be unable to connect, and full and incremental backups may fail, affecting services.
Solution:- Check whether applications are connected, optimize the connections, and release unnecessary connections.
- If this parameter is set to default, you can scale up the DB instance to set max_connections to a larger value. For details, see Changing a DB Instance Class.
- Check whether any metrics are abnormal and whether any alarms are generated on the Cloud Eye console. Cloud Eye monitors database metrics, such as the CPU usage, memory usage, storage space usage, and database connections, and allows you to set alarm policies to identify risks in advance if any alarms are generated. For details about the supported monitoring metrics, see Configuring Displayed Metrics.
- Run show variables like '%max%connections%'; to view the number of instance connections.
- Check whether the DB instance is in the Storage full state.
Check method: View the storage space usage on the RDS console or Cloud Eye.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot