I have 2 amazon ec2 instances.I want to connect from one to another. One has a Mysql database (instance 1). When I run the php code below on instance 2. I get a
ec2-x-x-x-x.us-west-2.compute.amazonaws.com is currently unable to handle this request.
But when I run the same code on http://phpfiddle.org/ the code works. Why does it not work on my server?
<?php
// On WEB_SERVER
$host="public Ip of instance 1"; // Host name
$username="test"; // Mysql usernam
$password="pass"; // Mysql password
$db_name="mydab"; // Database name
$db_port="3306";
// Create connection
$conn = new mysqli($host, $username, $password, $db_name,$db_port);
Check connection
if ($conn->connect_error) {
die('Connect Error (' . $mysqli->connect_errno . ') '
. $mysqli->connect_error);
}else
{
echo "connected";
}
?>