Connection Timed Out Error
Possible Causes:
- ECS is stopped.
- The access to the port is not allowed by the ECS security group.
- The port is not allowed in the ECS iptables.
- During the remote access to the MySQL databases, DNS resolution is slow. As a result, the connection times out.
ECS is stopped.
- Click the name of the target ECS. The page providing details about the ECS is displayed.
- If the ECS is stopped, restart the ECS. After it is restarted, connect to the database again.
The access to the port is not allowed by the ECS security group.
- You are advised to select TCP for Protocol/Application, enter the same port number as the self-built database port, and set the IP address to 0.0.0.0/0.
For details about how to set security group rules, see Configuring Security Group Rules.
Figure 1 Add Inbound Rule
- You are advised to select TCP for Protocol/Application, enter the same port number as the self-built database port, and set the IP address to 0.0.0.0/0.
For details about how to set security group rules, see Configuring Security Group Rules.
Figure 2 Add Outbound Rule
The port is not allowed in the ECS iptables.
- Locate the target ECS on the ECS console, click Remote Login in the Operation column, and enter the username and password. After successful login, run the following command to check the iptables configuration:
iptables -S

The port next to --dport indicates the port that can be accessed.
- You can add an iptables rule to allow access to the database port.
- You can run the following command to disable the firewall to allow access to the database port.
During the remote access to the MySQL databases, DNS resolution is slow. As a result, the connection times out.
- Locate the /etc/my.cnf configuration file of the MySQL database, enter the following content under [mysqld], save the modification, and exit.
skip-name-resolve

The default location of the MySQL configuration file is /etc/my.cnf. If the location is specified, you need modify it accordingly.
- Restart the database service with systemctl restart mysqld. Then, connect to the database again.
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.