Connect failed php_network_getaddresses: getaddrinfo failed: Name or service not known

Website URL

(please specify the URL of the site on which you are experiencing the problem)

Error Message

Connect failed php_network_getaddresses: getaddrinfo failed: Name or service not known

Other Information

I have this php file called connection.php that looks like


<?php
class Db
{
    //new version with user authentication
    private static $servername;
    private static $dbname;
    private static $admin_user;
    private static $admin_password;

    private static $init = False;
    public static $conn;

    public static function initialize(){
        //if(self::$init===TRUE)
          //  return;
        $servername = " sql213.epizy.com";
        $admin_user = "epiz_34115589";
        $admin_password = "xxxxxxxxxxxxx";  //checked that this is my hosting password
        $dbname = "epiz_34115589_bioactive_db";
        self::$init = TRUE;
        self::$conn=mysqli_connect($servername, $admin_user, $admin_password, $dbname);
    }
}
//initialize db
Db::initialize();
//check connection
if(!Db::$conn){
    die("Connect failed " . mysqli_connect_error());
}

Can you help me? I already looked at your MySQL connection issues page

Welcome!

Your server name is incorrect, there should not be any spaces included with the string.

Please remove the space and try the code again.

6 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.