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

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


Check your DB_HOST on your .env file

DB_HOST=http://localhost/ --> DB_HOST=localhost


Result:

I can migrate peacefully now.

php artisan migrateMigration table created successfully.Migrated: 2014_10_12_000000_create_users_table


Set DB_HOST=localhost and run the following artisan command

php artisan config:clear it will help you, clear cached config


I finally figured out what was causing this error for me. I'm using docker but I wasn't running php artisan migrate from the shell in the container. I was just running it in Terminal after navigating to the laravel project folder.Go to your docker dashboard and launch the CLI for the laravel container in the image for your project. Then run the migrate command.