-1

my code is as below

$dbhost = 'example.com';
$dbuser = 'dbusername';
$dbpass = 'dbpassword';
$dbName='dbname';
$conn = new mysqli($dbhost, $dbuser, $dbpass, $dbName);
// check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";

after i execute code getting below error Connection failed: Connection refused Warning: mysqli::__construct(): (HY000/2002): Connection timed out in /home/public_html/test/remote.php on line 8 Connection failed: Connection timed out

  • Sewakram Deshmukh - there is so much more you could say. Are you in control of the hosting server? The mysql database? What research have you done to try to solve your error? What else have you tried beyond what you have written here? There is no way for anybody else to know any of these things, so the more you tell us, the better chance we can help. –  May 07 '20 at 12:04
  • my code is in php,mysql,aws hosting,I have check 3306 port is also open. – Sewakram Deshmukh May 07 '20 at 12:15

1 Answers1

0

I don't know your environment, but my experience is that most publicly accessible webservers do not expose the SQL-database to the public, so the port is probably blocked. If you control the server, then you can probably find something in the firewall, but if you are using something like shared hosting, then you can really only try the helpdesk.

MultiSuperFreek
  • 417
  • 3
  • 8