Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

PDOException SQLSTATE[HY000] [2002] No such file or directory

I believe that I've successfully deployed my (very basic) site to fortrabbit, but as soon as I connect to SSH to run some commands (such as php artisan migrate or php artisan db:seed) I get an error message:
[PDOException]
SQLSTATE[HY000] [2002] No such file or directory


At some point the migration must have worked, because my tables are there - but this doesn't explain why it isn't working for me now.
by

3 Answers

rahul07
The error message indicates that a MySQL connection via socket is tried (which is not supported).

In the context of Laravel (artisan), you probably want to use a different / the correct environment. Eg: php artisan migrate --env=production (or whatever environment).
RoliMishra
If you are using Laravel Homestead, make sure you're calling the commands on the server.

homestead ssh

Then simply cd to the right directory and fire your command there.
pankajshivnani123
It worked after I change from DB_HOST=localhost to DB_HOST=127.0.0.1 at .env file

Login / Signup to Answer the Question.