SOLVED cPanel can't connect to MySQL server (Remote)

Michael Legg

Active Member
Mar 2, 2015
40
1
58
New Farm, Queensland, Australi
cPanel Access Level
Website Owner
After running fine for about 3 months. Our cPanel server suddenly can't connect to our MySQL server.

When I go to the MySQL profile editor and try to validate the MySQL server I get "Failed to “validate” Remote MySQL profile. 1 error occurred Unable to connect to the MySQL host 'xxx.xxx.xxx.xxx' Connection failed with error: Can't connect to MySQL server 'xxx.xxx.xxx.xxx' on (107)

MySQL is running and I can log in to it locally using the credentials cPanel uses.
There is nothing relevant in /var/log/mysqld.log on the MySQL server.
I can ping the MySQL server from the cPanel server, but when I try to connect to MySQL from the cpanel server I get "Can't connect to MySQL server on '192.168.0.11' (113)"

So one method reports a 107 error and the other reports a 113 error, but there are no further details.

Has anyone encountered this before?
 
Last edited:

Michael Legg

Active Member
Mar 2, 2015
40
1
58
New Farm, Queensland, Australi
cPanel Access Level
Website Owner
I found the problem, when the MySQL was rebooted last night it didn't load my iptables rules, so it was blocking all remote connections to MySQL.

I've re-enabled and re-saved the rules, but now I have to work out why they didn't load automatically.
 

Michael Legg

Active Member
Mar 2, 2015
40
1
58
New Farm, Queensland, Australi
cPanel Access Level
Website Owner
The problem was that I added my rules to iptables, unaware that Centos 7 uses firewalld to manage the firewall rather than the iptables service. So although the iptables rules work, firewalld is unaware of them and thus does not load them on reboot.

I've installed the iptables services and disabled firewalld so iptables now manages the firewall and will reload them on boot.
 

24x7server

Well-Known Member
Apr 17, 2013
1,911
96
78
India
cPanel Access Level
Root Administrator
Twitter
Hi,

To have it work even better I would suggest you use ConfigServer Firewall (CSF), which will make it easy for you to manage the firewall and then never face such issue again after a reboot..
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,202
363
Hello,

I'm glad to see you were able to solve the issue. Thank you for sharing the outcome.