mstnorris's avatar

composer require - PDOException: SQLSTATE[HY000] [2002] No such file or directory

I get the following error when I run composer require from my host machine. I'm running Laravel 5 with Homestead.

composer require graham-campbell/markdown
Warning: This development build of composer is over 30 days old. It is recommended to update it by running "/usr/local/bin/composer self-update" to get the latest version.
Using version ~3.0 for graham-campbell/markdown
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
PDOException: SQLSTATE[HY000] [2002] No such file or directory
Please configure your database connection correctly, or use the sqlite memory driver (-M). Skipping \Illuminate\Support\Facades\Password.
PDOException: SQLSTATE[HY000] [2002] No such file or directory
Please configure your database connection correctly, or use the sqlite memory driver (-M). Skipping \Illuminate\Support\Facades\Schema.
A new helper file was written to _ide_helper.php
Generating optimized class loader

It works absolutely fine with another project using very similar settings.

0 likes
5 replies
bobbybouwmann's avatar

The configuration of your database is not correct somehow! Can you post the database config you use? Just to make sure, you did fire the event inside your VM right?

1 like
mstnorris's avatar

I ran composer require ... from my host machine (my Mac), from within Homestead it works.

'mysql' => [
      'driver'    => 'mysql',
      'host'      => env('DB_HOST', 'localhost'),
      'database'  => env('DB_DATABASE', 'homestead'),
      'username'  => env('DB_USERNAME', 'homestead'),
      'password'  => env('DB_PASSWORD', 'secret'),
      'charset'   => 'utf8',
      'collation' => 'utf8_unicode_ci',
      'prefix'    => '',
      'strict'    => false,
],

I've checked with another project and I am using the same settings as above.

bobbybouwmann's avatar

Everything seems to be fine! Are you sure you have the correct values in your .env?

MrAlmostWrong's avatar

@mstnorris Did you ever find a solution to this? One of my projects just randomly started doing this. Has been working for 4 months and then today...poof.

Please or to participate in this conversation.