Generally our MySQL client experience error 10060 while trying to MySQL server over AWS cloud.
Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform related AWS queries.
In this context, we shall look into methods to resolve the error "RDS: ERROR 2003 (HY000): Can't connect to MySQL server (10060)".
The error message MySQL server sends back is:
"RDS: ERROR 2003 (HY000): Can't connect to MySQL server (10060)".
1. Configure public IP address in security groups
i. First and foremost we need to find the public IP address for the host machine where we run mysql-client. If we use the Amazon EC2 instance we can find the public IP here.
ii. Here, we go to the security groups and add the public IP address for inbound traffic.
iii. Then we add the same entry for outbound traffic by AWS services.
iv. Once done, we refresh the security groups and test the connection from any mysql-client.
For example, to test the connection we run the below command from any terminal where MySQL is configured:
mysql -h host-public-ip/DNS -P 3306 -u username -p password
2. Network ACLs
Network ACLs act as a firewall for resources in a specific subnet in a VPC. If we have ACLs, we ensure they have rules that allow all traffic to and from the DB instance.
i. Create a network ACL
We can create a custom network ACL. By default, a network ACL that we create blocks all traffic until we add rules:
If we add or delete a rule from an ACL, any subnets that associate with it are subject to change. We don’t have to terminate and relaunch the instances in the subnet. The changes take effect after a short period.
On the other hand, if we use the Amazon EC2 API or a command-line tool, we can't modify rules. Here, we can only add and delete rules.
With the Amazon VPC console, we can modify the entries for existing rules. On our behalf, the console removes the existing rule and adds a new rule.
In order to change a rule in the ACL, we must add a new rule with the new rule number, and then delete the original rule.
i. Add rules:
ii. Delete a rule:
This article covers methods to resolve AWS MySQL error 10060. This error is a result of the inbound connection rule set on your DB instance.
For each RDS database instance we create, there are Inbound & Outbound connection-security groups.
In AWS RDS console, under 'Databases', click on the 'DB Identifier' of your RDS instance. Then in the 'Security group rules' section, click on 'Inbound' type security group and edit the inbound rule to allow appropriate inbound connections.
You get 3 options here, under 'source' column: