I have created a new laravel project in laravel 8. I have set up Sail installation correctly, everything working fine for database connection in local but when I try to connect my database using sail it gives me an error
SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = laravel8 and table_name = migrations and table_type = 'BASE TABLE')
I have already cleared my config and cache files.
I was researching the same problem and found this.
https://github.com/laravel/sail/blob/7457004969dd62fa727fbc596bb2accccb1409a5/src/SailServiceProvider.php#L31
The code shows an artisan command added by laravel sail - sail:install
which overwrites your .env file host variables with service names.
I changed DB_HOST
from 127.0.0.1
to mysql
and it was fixed
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With