I believe I have successfully deployed my (very basic) site to fortrabbit, but once I connect to SSH to run some commands (such asphp artisan migrate
orphp 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 that doesn't explain why it's not working for me now.
One of the simplest causes of this error is that the MySQL server is not running. So check first. If it has started, continue with the other suggestions:
I encountered the exact same problem. None of the above solutions worked for me. I solved the problem by changing the "Host" in the /app/config/database.php file from "localhost" to "127.0.0.1".
Not sure why "localhost" doesn't work by default, but I found this answer in a similar problem solved in a symfony2 post.https://stackoverflow.com/a/9251924
renew:Some people asked why this fix works, so I did some research on the topic. As mentioned in this post, they seem to use different connection typeshttps://stackoverflow.com/a/9715164
The problem here is that "localhost" uses a UNIX socket and cannot find the database in the standard directory. However, "127.0.0.1" uses TCP (Transmission Control Protocol), which essentially means it runs over the "local internet" on your computer and is much more reliable than a UNIX socket in this case.
The error message indicates that a MySQL connection was attempted over a socket (not supported).
In the context of Laravel (Artisan) you may want to use a different/correct environment. For example:
php artisan migrate --env=product
(or any environment). Seehere.