Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel SQLSTATE[HY000] [2002] Connection refused

Tags:

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
like image 381
Mohammad Reza Avatar asked Dec 19 '16 15:12

Mohammad Reza


People also ask

Can't connect to Connection refused MySQL?

normally means that there is no MySQL server running on the system or that you are using an incorrect Unix socket file name or TCP/IP port number when trying to connect to the server. You should also check that the TCP/IP port you are using has not been blocked by a firewall or port blocking service.


1 Answers

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

like image 142
Arslan Khan Avatar answered Sep 20 '22 11:09

Arslan Khan