简体   繁体   中英

mysqli_connect connection error in GoDaddy

My system using core php and it is working fine in localhost. When I host into live then there is an error occurs site not working. I hosted in GoDaddy server and below are the code.

//connection code
<?php
$servername = "localhost";
$username = "*****";
$password = "*****";
$dbname = "******";

// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
} 
?>

But i get below error in browser

PHP Warning:  mysqli_connect(): (HY000/2002): No connection could be made because the target machine actively refused it.
in G:\PleskVhosts\projectname.com\httpdocs\pages\header.php on line 13

Please help me to fix it.

Not a problem in your code. May be service is not listing on your port or firewall is blocking your connection. In this case most possible reason is firewall.

You need to try "netstat -anb" for checking a running expected port. Here is a link my be help you: No connection could be made because the target machine actively refused it?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM