This happened to me out of nowhere, my app (Laravel) was working fine yesterday and dropped today with this error (SQLSTATE[HY000] [2002] No such file or directory).
After checking that my config file had not been not corrupted, I connected to my control panel (I am using a VPS) and restarted MySQL server. That did the trick, everything is back online.