Ad

Laravel Connection Refused Error

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 a SQLSTATE[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,
        ],
Ad

Answer

try adding mysql port in your database.php

        'driver'    => 'mysql',
        'host'      => env('DB_HOST', 'localhost'),
        'port'      => '33060',//your mysql port
Ad
source: stackoverflow.com
Ad