Laravel 5.5 SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: No such host is known

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47032410/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 16:53:25  来源:igfitidea点击:

Laravel 5.5 SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: No such host is known

phpmysqllaravellaravel-5.5

提问by nara_l

After installing Laravel 5.5 for a new project, I get this error:

为新项目安装 Laravel 5.5 后,出现此错误:

[Illuminate\Database\QueryException]
  SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: No such host is known.

.env db connection info:

.env 数据库连接信息:

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=lavavelproject
DB_USERNAME=root
DB_PASSWORD=

Dev environment: Windows PHP 7.0

开发环境:Windows PHP 7.0

回答by Adam Kozlowski

Try to clear cache by terminal:

尝试通过终端清除缓存:

php artisan config:cache

Do it always when you change config file.

更改配置文件时始终执行此操作。

回答by Option

Sometimes the most common issue is using localhost, change this to 127.0.0.1and it should work for you.

有时最常见的问题是使用localhost,将其更改为127.0.0.1它应该对您有用。

Sometimes you will have to run:

有时你必须运行:

php artisan cache:clearand in the rare moments as I have found also running php artisan key:generate

php artisan cache:clear在我发现的罕见时刻也在跑步 php artisan key:generate