SQLSTATE [HY000] [2002] php_network_getaddresses: getaddrinfo failed: nodename or servname provided or unknown

I keep this while working php artisan migrate

SQLSTATE [HY000] [2002] php_network_getaddresses: getaddrinfo failed: nodename or servname provided or unknown

My environment

  • Laravel Framework Version 5.1.20 (LTS)
  • Laravel Installer version 1.2.0
  • PHP 5.6.14 (cli) (built: October 2, 2015 08:55:56)
  • mysql Ver 14.14. Distribution 5.6.24, for osx10.10 (x86_64)

.env

APP_ENV=local
APP_URL=http://localhost/
APP_DEBUG=true
APP_KEY=****

DB_HOST=http://localhost/
DB_DATABASE=name-local
DB_USERNAME=root
DB_PASSWORD=
UNIX_SOCKET = /tmp/mysql.sock

This database name-localexists in my local database.

Any tips / suggestions would be a huge help for me.

+4
source share
2 answers

Check DB_HOSTin file.env

DB_HOST=http://localhost/DB_HOST=localhost


Result:

Now I can migrate peacefully.

php artisan migrate
Migration table created successfully.
Migrated: 2014_10_12_000000_create_users_table
+6
source

DB_HOST=localhost

php artisan config:clear ,

+3

Source: https://habr.com/ru/post/1612590/


All Articles