spsaravananct
spsaravananct

Reputation: 394

Laravel And AWS RDS Migration Cannot Connect Database

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_',
    ),

Upvotes: 1

Views: 1770

Answers (2)

Eduardo Cruz
Eduardo Cruz

Reputation: 617

Try replacing the host name with an IP address

Upvotes: 0

TrueStory
TrueStory

Reputation: 439

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.

Upvotes: 1

Related Questions