0

I have a mariaDB service running on a remote server A. I have a second remote server B running httpd. Both server A and B's NAT firewall allows all traffic for port 3306 and ICMP. Server B allows port 80 as well. The mariaDB server A has a user 'foouser'@'[IPofServerB]' granted select privilege; Privileges have been flushed. In addition I also granted 'foouser'@'%' the same permissions.

Server A's my.conf has bind-address set to 0.0.0.0 and skip-networking commented (I have also tried commenting bind-address outright), firewalld includes a rule allowing TCP on port 3306, I used setsebool -P httpd_can_network_connect_db 1 to allow connections from apache in SELinux, and iptables show port 3306 listening. Server B's firewalld also includes a rule allowing TCP on port 3306.

I can ping A and B from my home computer, and A from B, and B from A. I can connect to the mariaDB server A from my home computer running apache from XAMP, with foouser'@'IPofHomeComputer granted the exact same access. I cannot connect to the mariaDB server A from B. I get Connection failed: Can't connect to MySQL server on '[IPofServerA]' (110).

In both cases I have the exact same PHP code attempting the connection:

<?php
$servername = "[IPofServerA]";
$username = "foouser";
$password = "[foouserPasswd]";
$dbname = "[databaseInQuestion]";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
}
?>
  • Double check your firewall. In particular also check the firewall which is external to the server. – Michael Hampton Jun 16 at 6:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.