[SOLVED] Illuminate\Database\QueryException SQLSTATE[HY000] [2002] Connection refused (SQL: select count(*) as aggregate from `products`) LARAVEL 6 MAMP

If you are using mysql from mamp for your laravel application and getting following error while displaying the data inside your application

Illuminate\Database\QueryException
SQLSTATE[HY000] [2002] Connection refused (SQL: select count(*) as aggregate from `products`)

Then you can solve this issue by just adding following line inside your .env file below the connection settings

DB_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock

It will solve your issue.

Leave a Reply

Your email address will not be published. Required fields are marked *