title: PDO connection refused with laravel, but not with $con = new PDO()
body: <p>I've configured mysql for my laravel 5.0-dev project like so:</p>
  
  <pre><code>'mysql' =&gt; [
      'driver'    =&gt; 'mysql',
      'host'      =&gt; env('DB_HOST') ?: 'localhost',
      'database'  =&gt; env('DB_DATABASE') ?: 'homestead',
      'username'  =&gt; env('DB_USERNAME') ?: 'homestead',
      'password'  =&gt; env('DB_PASSWORD') ?: 'secret',
      'charset'   =&gt; 'utf8',
      'collation' =&gt; 'utf8_unicode_ci',
      'prefix'    =&gt; '',
      'strict'    =&gt; false,
  ],
  </code></pre>
  
  <p>However, I get connection refused ('PDOException' with message 'SQLSTATE[HY000] [2002]') whenever I try to interact with the database using either php artisan, or the laravel app itself.</p>
  
  <p>The weird thing is, when I run the code below, the connection doesn't get refused.</p>
  
  <pre><code>&lt;?php
  $dsn = 'mysql:dbname=homestead;host=localhost';
  $user = 'homestead';
  $password = 'secret';
  
  try
  {
      $dbh = new PDO($dsn, $user, $password);
  }
  catch (PDOException $e)
  {
      echo 'Connection failed: ' . $e-&gt;getMessage();
  }
  </code></pre>
  
  <p>I've been googling for 3 hours now and I haven't found a single solution which actually works. So any help is greatly appreciated.</p>