1
votes

Hi I am new to laravel in my app when i connecting database i got following error

SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known

public function createConnection($dsn, array $config, array $options)
{
$username = array_get($config, 'username');
$password = array_get($config, 'password');
**return new PDO($dsn, $username, $password, $options);**
}
 'mysql' => array(
        'driver'    => 'mysql',
        'host'      => 'HOST NAME',
        'port'      => '3306',
        'database'  => 'DBNAME',
        'username'  => 'DBUSER',
        'password'  => 'DBPASSWORD',
        'charset'   => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix'    => 'vox_',
    ),
2
Please post the relevant database config from app/config/database.php (excluding the password of course).Bogdan
I have updated db detailsspsaravananct
Are you able to connect using a remote client (like MySQL Workbench) to that database using your credentials?Bogdan

2 Answers

1
votes

This might be pretty obvious, but

 'host'      => 'HOST NAME',
        'port'      => '3306',
        'database'  => 'DBNAME',
        'username'  => 'DBUSER',
        'password'  => 'DBPASSWORD',

those are set to strings HOST NAME, DBNAME, etc. hardcode your DB credentials and see if it works.

0
votes

Try replacing the host name with an IP address