Laravel Connection Refused Error
18,644
Solution 1
try adding mysql port in your database.php
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => '33060',//your mysql port
Solution 2
If you are using MAMP be sure to add the unix_socket key with a value of the path that the mysql.sock resides in MAMP.
'mysql' => array(
'driver' => 'mysql',
'host' => 'localhost',
'unix_socket' => '/Applications/MAMP/tmp/mysql/mysql.sock',
'database' => 'database',
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
Author by
Ollie
Updated on June 08, 2022Comments
-
Ollie almost 2 years
I'm aware this is a repeat question, but none of the solutions online seem to be working for me.
I'm trying to add authentication to a laravel 5 project (using
make:auth
) Whenever I try to 'register', I get aSQLSTATE[HY000] [2002] Connection refused
error.The responses online have been to change localhost to 127.0.0.1 and vise-vera, but that isn't working for me.
Any idea anyone? Thanks (I'm on OSX, if that makes a difference at all)
.env DB_HOST=localhost DB_DATABASE=test DB_USERNAME=test DB_PASSWORD=
database.php 'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', 'localhost'), 'database' => env('DB_DATABASE', 'test'), 'username' => env('DB_USERNAME', 'test'), 'password' => env('DB_PASSWORD', ''), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, ],
-
brunoramonalmeida almost 6 yearsThis should be the right answer! Thanks. It worked on High Sierra