Php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution [duplicate]

  android-volley, mysql, php, phpmyadmin, server

I have install my UBUNTU SERVER 20.04 on my little home server.
I am trying to start a php script to put image on my phpMyAdmin database with MySQL.

This is php script that is insert on my server at

$user_name = "root";
$user_pass = "";
$host_name = "";
$db_name = "dbupload";

$con = mysqli_connect($host_name, $user_name, $user_pass) or die("Unable to connect to MySQL " . mysqli_connect_error());

if ($con) {
    $image = $_POST["image"];
    $name = $_POST["name"];
    $sql = "insert into imageinfo(name) values ('$name')";
    $upload_path = "uploads/$name.jpg";

    if (mysqli_query($con, $sql)) {
        file_put_contents($upload_path, base64_decode(($image)));
        echo json_encode(array('response' => 'Image Uploaded Successfully'));
    } else {
        echo json_encode(array('response' => 'Image Uploaded failed'));
} else {
    echo json_encode(array('response' => 'not connected!'));


My server have static ip and i have phpMyAdmin on

My username is set to root and i remove my password ( ” ).

The response of the script is Unable to connect to MySQL php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution

but when i ping it works.

How can i do?

Source: Ask PHP