×


AWS MySQL error 10060 – Can't connect to MySQL server ?

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)".


Nature of AWS MySQL error 10060 ?

The error message MySQL server sends back is:

"RDS: ERROR 2003 (HY000): Can't connect to MySQL server (10060)".
  • It states that the inbound/outbound traffic from the AWS instance is not reachable to the current host where we run the MySQL client.
  • So we need to register the public IP address in the RDS security groups to get access over the RDS MySQL instance.


How to fix AWS MySQL error 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:

  • Initially, we open the Amazon VPC console at https://console.aws.amazon.com/vpc/.
  • In the navigation pane, we choose Network ACLs.
  • Then we choose Create Network ACL.
  • In the Create Network ACL dialog box, optionally name the network ACL, and select the ID of the VPC from the VPC list.
  • Then we choose Yes > Create.


How to Add and delete rules from a network ACL ?

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:

  • Open the Amazon VPC console at https://console.aws.amazon.com/vpc/.
  • In the navigation pane, we choose Network ACLs.
  • Then in the details pane, we choose either the Inbound Rules or Outbound Rules, then choose Edit.
  • In Rule #, we enter a rule number (for example, 100). The rule number must not already be in use in the network ACL.
  • We recommend leaving gaps between the rule numbers because it makes it easier to add a new rule without having to renumber the existing rules.
  • We select a rule from the Type list. For example, to add a rule for HTTP, choose HTTP. To use a protocol, not on the list, we choose Custom Protocol Rule.
  • In case of a custom protocol rule, select the protocol’s number and name from the Protocol list.
  • Then in the Source or Destination field, we enter the CIDR range that the rule applies to.
  • From the Allow/Deny list, we select ALLOW to allow traffic or DENY to deny traffic.
  • In case we want to add another rule, we select Add another rule and repeat steps 4 to 9 as required.
  • Once done, choose Save.


ii. Delete a rule:

  • We open the Amazon VPC console at https://console.aws.amazon.com/vpc/.
  • In the navigation pane, we choose Network ACLs and select the network ACL.
  • In the details pane, select either the Inbound Rules or Outbound Rules tab, and then choose Edit.
  • We can select Remove for the rule we want to delete, and then Save.


[Need help with fixing MySQL errors? We can help you. ]


Conclusion

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:

  • Custom.
  • Anywhere (Allows connections from any IP. Not recommended for production.).
  • My IP (Automatically detects your machine's IP).