I have used Laravel 5.7. I get this error only in production, locally my app runs smoothly. I've tried changing:
'host' => env('DB_HOST', '127.0.0.1')
To
'host' => env('DB_HOST', 'localhost') in config/database.php
Just set up correct Database credentials:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE= // Your Database Name
DB_USERNAME= // Yout Database Username
DB_PASSWORD= // Your Database Password
After completion of .env edit please enter this command in your terminal for clear cache: php artisan config:cache
.envfile for database configuration? - Ankur Tiwari'homestead'@'localhost'on the production environment is correct? - Koala Yeung