Laravel

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

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

[Or] Error : (2002) No such file or directory

Once I deployed my project into server I have faced PDOException SQLSTATE[HY000] [2002] No such file or directory exception error.
So I have fixed it by below steps:

17educations-pdoexception-sqlstatehy000-2002-no-such-file-or-directory

Step 1 :

Check Do you have all the necessary extensions installed on the server?

 Step 2 :

 Step 3 :

Generate key and Paste it in you app.php file and the below commad will automically set key to .env file.



 Step 4:

Check your .env file as like:

 

If you are getting error in Mamp Please check your database.php file.

 

Thats it, Now your project will work like charm.
Thanks!. If you like this article dont forget to share and commnt.