I am using a Laravel 9 installation that is running perfectly on localhost.
When I add 127.0.0.1 myapp.local
to my /etc/hosts
(MacOS), I get a
SQLSTATE[HY000] [2002] Connection refused
I am using MariaDB in a docker container together with nginx, where I added I vhost for myapp.local
. When I don't use a mysql connection, Laravel is working.
My .env
file has DB_HOST=127.0.0.1
and I tried localhost
, 0.0.0.0
, myapp.local
as well with the same error message.
The DB_USERNAME
has access to %
host.
I needed to use the docker container name as host name.