In this section, we’ll address how to resolve the SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it error in Laravel.
![SQLSTATE[HY000] [2002] No connection](https://larainfo.com/wp-content/uploads/2024/05/N9gKqTinDaVTFg5FMKLDqMtJowB8W18NGfqRcUiP.png)
Laravel Solve SQLSTATE[HY000] [2002]
If you encounter this error, please ensure that your XAMPP connection is active. If it’s inactive, turn on both MySQL and Apache services.
![xampp connection solve SQLSTATE[HY000] [2002]](https://larainfo.com/wp-content/uploads/2024/05/vTFeVXYbzs06RBt8Vv8KxQsAAvUQAoRY7zWO84rS.png)
If the previous solution doesn’t resolve the issue, you can try the following steps:
- Modify the
.env
file by changing the host from127.0.0.1
tolocalhost
. - Run the Laravel config cache command using
php artisan config:cache
. - Verify the
config/database.php
file to see if there are any changes or misconfigurations.
These steps may help in resolving the SQLSTATE[HY000] [2002] error.