I'm running a vagrant box and with laravel 5. For some reason when running php artisan
it throws the following error:
SQLSTATE[HY000] [2002] Connection refused
This happens when I have my host
set to 127.0.0.1
. When using localhost
I get File or directory not found
.
The strange part is that the website itself works fine in the browser. This only happens in php artisan
.
I also tried changing ports between 3306
and 33060
.
Any ideas?
EDIT:
I did the following in the laravel index.php
file:
$pdo = new PDO('mysql:host=127.0.0.1;dbname=mydb','root','mypassword');
var_dump(get_class_methods($pdo));
die();
and it worked fine. Inside the Connector.php
file I checked the variables being passed to the PDO
constructor and they were identical to what I filled in above. What is going on?