Mysqli_connect (): php_network_getaddresses: getaddrinfo failed: name or service unknown

im works on a website that mainly uses a database. The problem is that im gets the following error: mysqli_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known I cannot figure out how to fix this. I have a penta connection check, and everything seems to be in order.

 function connect($hostname, $username, $password, $database) { $conid = mysqli_connect($hostname, $username, $password, TRUE); if($conid == FALSE) { if(DEBUG == TRUE) { show_error("MySQL Connection using `$hostname`, `$username`, `$password` was refused"); } return; } else { $dbid = mysqli_select_db($database, $conid); if($dbid == FALSE) { if(DEBUG == TRUE) { show_error("MySQL could not connect to database `$database`"); } return; } else { self::$connections[] = $conid; self::$connection = $conid; } } } 

The code was written in 2010, and then somehow it worked. Can I fix it?

+6
source share
3 answers

This is a server location issue. You will need to check the hosting.

You can also read more tips at this link: http://albertech.net/2011/05/fix-php_network_getaddresses-getaddrinfo-failed-name-or-service-not-known/

+3
source

I had a similar problem, "My problem" was resolved by checking and resolving DNS resolution (in our case, use in cagefs had different / etc / hosts than the main system)

0
source

Your PHP server has been updated and your hosting does not support it.

-1
source

All Articles