mysqli::mysqli(): php_network_getaddresses: getaddrinfo failed: Name or service not known
Problem is with this line.
$mysqli = new mysqli('$host','$user','$pass','$database');
Change it to
$mysqli = new mysqli($host,$user,$pass,$database);
In PHP variables within single quotes are not interpolated with their values.
Check PHP's variable parsing mechanism here