Laravel SQLSTATE[HY000] [2002] Connection refused

so I want to deploy my existing Laravel project into my digital ocean VPS I used this tutorial and I uploaded my site successfully.

My .env file is:

APP_ENV=local
APP_KEY=my app key
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost

DB_CONNECTION=mysql
DB_HOST=my ip
DB_PORT=3306
DB_DATABASE=form
DB_USERNAME=root
DB_PASSWORD=my pass

But here is the problem: I used MySQL and created and ran

php artisan migrate

and got these errors:

[Illuminate\Database\QueryException] SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = form and table_name = migrations)

and

[PDOException] SQLSTATE[HY000] [2002] Connection refused

Solution 1:

In your .env file, change DB_HOST from 127.0.0.1 to localhost

Solution 2:

Put string:

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

after DB_PASSWORD=

It works for MAMP. Set your path to mysql.sock