Cause:
Incorrect database credentials or missing configuration in .env file.
Solution:
-
In cPanel, open File Manager → Laravel project root → .env
-
Make sure these values are correct:
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=your_db_name
DB_USERNAME=your_db_user
DB_PASSWORD=your_db_pass
- Save file and clear config cache:
php artisan config:clear
-
Refresh your website.
Database will connect successfully.