phpmysqllaravellaravel-5

Connection to DB with socket refused in Laravel


I'm aware of a ton of hits on SO and Google about this issue, still I have a unique problem it seems.

Error message: SQLSTATE[HY000] [2002] Connection refused

Configuration

    'mysql' => array(
        'driver'    => 'mysql',
        "host"      => "localhost:/var/run/mysqld4.sock",
        'port'      => '3304',
        "username"  => "admin",
        "password"  => "admin",
        "database"  => "frontend_generic",
        'charset'   => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix'    => 'pre_',
    ),

I confirmed that my database is running on port 3304, my prefix is correct, as are user, database and password.

For host I tried "localhost", "127.0.0.1", "http://127.0.0.1" and even the actual ip-address of the server.

Still, there is no luck or change. I tried using the exact same configuration in the local database.php file, but as expected, nothing changes.

Out of options, what am I missing here?

Update:

This is code from another app that works with this configuration. This is Kohana, not Laravel, but it works.

 "general" => array
        (
            "type"       => "mysql",
            "connection" => array
            (
                "hostname"   => "localhost:/var/run/mysqld4.sock",
                "username"   => "admin",
                "password"   => "admin",
                "persistent" => FALSE,
                "database"   => "frontend_generic",
            ),
            "table_prefix" => "pre_",
            "charset"      => "utf8",
            "caching"      => FALSE,
            "profiling"    => TRUE,
        ),

Solution

  • You should change "host" to the actual server IP adres, and nothing else. So, get rid of the socket stuff.