No matter how I slice it I can never get to success with Laravel & Sail. I've spun up maybe 30 Laravel Installs over the last couple months. And its ALWAYS the same return. Here's exactly what I do each and every time...
1
MacOS
Win11
Win10
2
- cd example-app
- ./vendor/bin/sail up
3
Illuminate\Database\QueryException
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for mysql failed: nodename nor servname provided, or not known (SQL: select * from information_schema.tables where table_schema = application and table_name = migrations and table_type = 'BASE TABLE')
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:742
738▕ // If an exception occurs when attempting to run a query, we'll format the error
739▕ // message to include the bindings with SQL, which will make this exception a
740▕ // lot more helpful to the developer instead of just the database's errors.
741▕ catch (Exception $e) {
➜ 742▕ throw new QueryException(
743▕ $query, $this->prepareBindings($bindings), $e
744▕ );
745▕ }
746▕ }
4
NOTHING WORKS. Every single last install is the same. Not ONCE ever once has it ever not thrown this error on ANY setup, any workstation at all. Not worked a single time. Hopefully I've established the importance there. I've not successfully ever been able to use Laravel -- I even purchase a new computer as a solve. NOPE. All fresh everything this same exact error always populates.
5
- I confirm my db user and pass and all that is good by inspecting using this...
docker inspect application-mysql-1
6
- CANNOT php artisan migrate
7
- I go to the .env file and change the db_host from "mysql" to 127.0.0.1 (from mysql that laravel inserts) and then I am able to migrate alls good but now my application will not reach the database. I have to manually revert back from 127.0.0.1 to mysql!!!!! EVERY last time. Simple: If I need to php artisan migrate I have to update my env file as explained right before this. And than revert back.
8
Laravel will just not work. No matter how much time (months now) no matter how much money. No matter what it just does not work. I don't know what to do here. I've purchases new gear, I've tried a hundred things. And nothing will fix Laravel and get it to a working state.