0
votes

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

1
Have you change the .env file for database configuration? - Ankur Tiwari
Are you sure that your database password for 'homestead'@'localhost' on the production environment is correct? - Koala Yeung
yes i'm sure my database password is correct on production environment - Manoz Thapa
Doesn't the IP for localhost always resolve to 127.0.0.1? So they are the same thing? - party-ring

1 Answers

1
votes

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