Laravel SQLSTATE[HY000] [2002] Connection refused within macOs

If you are in mac environment and using Laravel and mysql and encounter such an error:

SQLSTATE[HY000] [2002] Connection refused

The solution would be:

Just open the mysql config file at /usr/local/etc/my.cnf with your editor and comment out the following line:

!includedir /usr/local/etc/my.cnf.d

It should be the same as :

# !includedir /usr/local/etc/my.cnf.d

Posting daily about Python, Nuclear Physicist PhD