• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 692
  • Last Modified:

Cannot access remote mysql host on a CPanel server

I have a script that is residing on a Plesk server. I have another server that's running CPanel to host the MySQL server.

In Cpanel and WHM I have added the IP of the plesk server to the Remote Database Access Hosts and Additional MySQL Access Hosts respectively.

However when I try to run the script I get the following error:

Warning: mysqli::real_connect() [function.mysqli-real-connect]: (HY000/2003): Can't connect to MySQL server on '173.199.132.92' (4) in /var/www/vhosts/feedsmanagement.com/httpdocs/cp/lib/SimpleTools/SimpleMySQL.php on line 193
Connection error: Can't connect to MySQL server on '173.199.132.92' (4)
Please correct your details and try again.

So what else do I need to do to get the connection to work?

Thanks!
0
AnuarJamlus
Asked:
AnuarJamlus
  • 4
  • 4
1 Solution
 
yadayaCommented:
Check firewall on src and dst host. is they allow connections on mysql port.
0
 
AnuarJamlusAuthor Commented:
The plesk server which is on 1and1 hosting has a firewall and I have allowed outgoing access to port 3306.

The mysql server itself does not have any firewall, or if there is I don't know about it. However I've never had to deal with firewalls while working on a cpanel/whm server.
0
 
yadayaCommented:
test outbound connection on plesk server port 3306

telnet <dst ip> 3306

Open in new window

0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
AnuarJamlusAuthor Commented:
At the moment it is stuck at

Trying 173.199.132.92...

Does that mean it's the plesk firewall that's blocking?
0
 
yadayaCommented:
yes. you cant connect on 3306 mysql port.

reconfigure or turnoff firewall.

and one thing more, test is dst host reacheble:

ping <dst ip>

Open in new window


0
 
yadayaCommented:
and,  check you firewall rules on both servers:
iptables-save

Open in new window

0
 
shaunakCommented:
In your cpanel, Database> You need to add the ip to allowed host to connect to database.
You can get that in : Remote Database Access Hosts. Add the ip from which you are trying to connect to database. Also make sure that port 3306 is allowed for all incoming and outgoing traffic.
0
 
AnuarJamlusAuthor Commented:
OK I think it's the server that's hosting the mysql database that isn't accepting connections.

So how do I allow it to accept connections. It's running Cpanel and WHM. I have already added the IP to the Remote Database Access Hosts so it's got to be something else.
0
 
AnuarJamlusAuthor Commented:
The server where the mysql database is hosted on apparently has a ConfigServer Firewall installed. So in the end all it took was to add the other server's IP to the allow list.

Thanks!
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now