laravel访问报错SQLSTATE[HY000] [2002] Connection refused
laravel 8,首次访问报错如下:
SQLSTATE[HY000] [2002] Connection refused (SQL: select * from `sessions` where `id` = g9NiFsTVwmc4sbj2JuAWZHhriQ9w1QQDUgu0ehMO limit 1)
分析:项目运行于laradock,而.env默认的MySQL数据库的连接地址是127.0.0.1,需要改成docker物理机的IP地址
解决:编辑.env,把DB_HOST=127.0.0.1改成DB_HOST=172.21.214.179