0
votes

I've got this error:

SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known

and

PDO::__construct(): php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known.

When I try to run php artisan serve in terminal I got always same error. did anyone already solved this Problem ?

I use Xampp on Mac.

This's my database.php.

'mysql' => [
    'driver' => 'mysql',
    'host' => env('DB_HOST', 'localhostphp artisan make:migration create_users_table'),
    'port' => env('DB_PORT', '3306'),
    'database' => env('DB_DATABASE', 'forge'),
    'username' => env('DB_USERNAME', 'forge'),
    'password' => env('DB_PASSWORD', ''),
    'charset' => 'utf8',
    'collation' => 'utf8_unicode_ci',
    'prefix' => '',
    'strict' => false,
    'engine' => null,
],

and this one is my env.

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=-----
DB_USERNAME=------
DB_PASSWORD=------

I got this two error. since 2 week I try to solve a problem. but I could't find solution. I've already done all solution on stackoverflow.

Thaks For Your Help.

Link : https://imgyukle.com/i/oEJWhR

1
Is 127.0.0.1 localhost set in your /etc/hosts file?matticustard
it's localhost.sdk
I understand you're using localhost. I was asking if the line 127.0.0.1 localhost exists in your /etc/hosts file to bind that IP to localhost. It should exist and be uncommented.matticustard

1 Answers

0
votes

I'm pretty sure it's because of the host's line! It should be

'host' => env('DB_HOST', 'localhost'),

OR

'host' => env('DB_HOST', '127.0.0.1'),

This part of the line php artisan make:migration create_users_table is a Laravel command! You're supposed to do it in the command line (the terminal)!