Mysqli_connect(): (HY000/2002): Connection refused in

Hi I am trying to get my site up and running however that is the issue I receive when attempting to log in. Here is my code:

function connect() {

    //set up variables used to connect to MySQL
    $dbhost = 'localhost:3306';
    $dbuser = 'id5390170_root';
    $dbpass = '*****';

    //connect to MySQL
    $link = mysqli_connect($dbhost, $dbuser, $dbpass);
    if (!$link) {
        die('Could not connect to MySQL:' . mysqli_errno($link));
    }

    //select shopper database
    $retval = mysqli_select_db($link, 'id5390170_ineventory');
    if (!$retval) {
        die('Could not select database:' . mysqli_errno($link));
    }

    return $link;
}

And I get the error: mysqli_connect(): (HY000/2002): Connection refused in

Do not use :3306.
Just use localhost :slight_smile:

Thank you that worked perfectly

1 Like