2

In short, I have this issue:

local server --> remote db server : Connected successfully

other remote server --> remote db server : Connection refused

The story:

Because of my web hosting (iPage) has limited resources for shared hosting plan, especially for Mysql, I decided to connect one of my websites (WordPress) to remote MySQL server, So I got another shared hosting plan based on cPanel from another provider, when I complete setting up my database and add my remote host (iPage) to access host settings in cPanel (actually I also added % to access host just for testing :)) and I added the new credentials to wp-config.php, and go to my website I noted that the website couldn't connect to the database. here I started to troubleshooting, I used this PHP script to check the errors,

    <?php
$servername = "my_remote_host_ip";
$username = "my_db_user";
$password = "my_db_pass";

// Create connection
$conn = new mysqli($servername, $username, $password);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 
echo "Connected successfully";    
?>

it gives me:

Connection failed: Connection refused

But when I run this script from local (LAMP) server it gives me:

Connected successfully

also everything works fine, it connects from my ubuntu laptop via MySQL workbench and via terminal

mysql -h my_remote_host_ip -u my_db_user -p

Do you have any ideas about this issue

TIA

SaFi2266
  • 21
  • 5
  • 1
    Have you checked enabling remote MySQL connections as described here: https://stackoverflow.com/questions/14779104/how-to-allow-remote-connection-to-mysql? Also ensure that the MySQL port (3306 by default) is open in your firewall. – M. F. Mar 05 '18 at 18:08
  • I have limited non root access to db remote server, but I test it on my laptop and it seems works and connects even when I telnet it with port 3306, all connections established, but it is not from another server .. thanks for reminding me and thanks for your attention – SaFi2266 Mar 05 '18 at 20:29

0 Answers0