A Laravel 500 error is frustrating because the browser often gives you almost nothing: 500 Internal Server Error, a blank white page, or a generic server message. The useful information is usually somewhere else: Laravel logs, web server logs, PHP-FPM logs, environment configuration, file permissions, or cached config.
This guide is written for the moment when a Laravel app is not working and you need to diagnose it quickly. Start with the logs, avoid guessing, and work through the most common failure points in order.
If you are still learning the framework, keep the Laravel Complete Guide nearby. If the error appears in a new local project, review How to Install Laravel. If the error is tied to a route, controller, or missing endpoint, check Laravel Routing Explained.
What Does a Laravel 500 Error Mean?
A 500 error means the server failed while trying to handle the request. In Laravel, that failure might come from your application code, a missing environment value, a bad database connection, a broken Composer install, a web server misconfiguration, or a file the PHP process cannot write to.
The key point: a 500 error is not the root cause. It is the symptom. Your job is to find the exception or server error behind it.
Where Laravel Errors Are Logged
Laravel writes application logs based on the logging configuration in config/logging.php. In many projects, the default local log file is:
storage/logs/laravel.log
Depending on LOG_CHANNEL, you may also see daily logs, stderr logs, syslog entries, or external logging services. If storage/logs/laravel.log is empty, check your LOG_CHANNEL value and the server-level logs.
On a VPS, also check:
- Apache error logs
- Nginx error logs
- PHP-FPM logs
- systemd service logs for queue workers, schedulers, or custom services
tail -n 100 storage/logs/laravel.log
# Common Linux server locations vary by distro and setup:
sudo tail -n 100 /var/log/nginx/error.log
sudo tail -n 100 /var/log/apache2/error.log
sudo journalctl -u php8.2-fpm -n 100 --no-pager
Do not start by changing random code. Read the latest error first. The exception message usually points to the correct area.
Enable Debug Mode Safely
In local development, debug mode helps you see full exception pages:
APP_ENV=local
APP_DEBUG=true
In production, keep debug mode off:
APP_ENV=production
APP_DEBUG=false
Turning on APP_DEBUG=true publicly can expose sensitive paths, environment details, stack traces, configuration values, and code context. If you must temporarily inspect a production error, prefer logs, private staging, restricted access, or server-side debugging. Turn debug mode back off immediately after diagnosis.
After changing .env on a server that uses cached configuration, clear or rebuild config cache:
php artisan config:clear
php artisan optimize:clear
Check storage/logs
Open the newest Laravel log entry and read from the first exception line downward. You are looking for the actual class, file, and message behind the Laravel Internal Server Error.
cd /path/to/your/laravel-app
tail -n 200 storage/logs/laravel.log
Common messages point to clear next steps:
No application encryption key has been specified: fixAPP_KEY.SQLSTATE: check database credentials, host, port, schema, user permissions, and migrations.Class ... not found: check Composer dependencies and autoloading.Permission denied: check ownership and write permissions forstorageandbootstrap/cache.View ... not found: check Blade path/name and clear compiled views.
Check .env Configuration
A bad .env file is one of the most common causes of Laravel production errors after deployment. Confirm the file exists on the server and contains the values the app actually needs.
ls -la .env
php artisan about
Check these values first:
APP_NAME="Your App"
APP_ENV=production
APP_KEY=base64:...
APP_DEBUG=false
APP_URL=https://example.com
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=example
DB_USERNAME=example_user
DB_PASSWORD=secret
CACHE_STORE=file
QUEUE_CONNECTION=database
SESSION_DRIVER=file
LOG_CHANNEL=stack
Be careful with quotes. Values containing spaces, special characters, or hash signs are safer when quoted. After any .env correction, clear cached config.
php artisan config:clear
Future internal-link opportunity: Laravel Environment Configuration.
Fix APP_KEY Issues
Laravel requires an application key for encryption-related features. A missing key can break sessions, encrypted cookies, password reset tokens, and other features.
If this is a new application and no key exists, generate one:
php artisan key:generate
php artisan config:clear
Do not casually regenerate APP_KEY on an existing production app. Changing it can invalidate encrypted data and sessions. If the production key was lost, treat it as a serious incident and confirm whether the app stores encrypted values that depend on the old key.
Clear Laravel Cache
Laravel can cache configuration, routes, events, views, and application cache values. Stale cache is a common reason a deployment keeps using old settings even after you edited .env or route files.
php artisan config:clear
php artisan cache:clear
php artisan route:clear
php artisan view:clear
php artisan optimize:clear
optimize:clear is the broad reset command for Laravel’s generated optimization files and default cache driver. If you only need one quick first move during troubleshooting, use it.
After the error is fixed, production deployments commonly rebuild caches:
php artisan config:cache
php artisan route:cache
php artisan view:cache
Future internal-link opportunity: Laravel Caching Guide.
Fix Permission Problems
Laravel needs write access to storage and bootstrap/cache. If the web server cannot write there, you may see 500 errors, failed sessions, failed logs, broken compiled views, or cache write exceptions.
sudo chown -R www-data:www-data storage bootstrap/cache
sudo find storage bootstrap/cache -type d -exec chmod 775 {} ;
sudo find storage bootstrap/cache -type f -exec chmod 664 {} ;
The correct user may be different on your server. Common web server users include www-data, nginx, apache, or a deployment-specific user. Check your PHP-FPM pool or web server config before copying ownership commands blindly.
Avoid setting the whole project to 777. It may hide the problem temporarily while creating a security risk.
Check Composer Dependencies
If a deployment misses packages, uses the wrong Composer mode, or uploads code without vendor, Laravel can fail during bootstrap or when a class is used.
composer install --no-dev --optimize-autoloader
composer dump-autoload
php artisan optimize:clear
Use --no-dev for production when development packages are not needed. If your application accidentally depends on a dev-only package at runtime, production may throw class-not-found errors. The fix is not to install every dev package on production; the better fix is to move runtime dependencies into the correct Composer section or remove the runtime dependency.
Check PHP Version Compatibility
Laravel 12 requires PHP 8.2 or newer. A server running an older PHP version can produce fatal errors before Laravel has a chance to render a helpful exception page.
php -v
php -m
composer check-platform-reqs
Also confirm that the CLI PHP version and web server PHP version match. It is possible for php -v in SSH to show one version while PHP-FPM or Apache uses another.
Laravel also depends on common PHP extensions. If Composer reports missing extensions, install them for the PHP version used by the web server and restart PHP-FPM or Apache.
Check Database Connection Issues
Database failures often appear as Laravel Error 500 pages because the application cannot read or write required data. Look for SQLSTATE in the Laravel log.
php artisan migrate:status
php artisan tinker
DB::connection()->getPdo();
Check these items:
- Database host and port are correct.
- The database exists.
- The database user has the required permissions.
- The server firewall allows the connection.
- The app has run required migrations.
- The production server uses the intended
.envfile.
Do not run destructive migrations or resets on production while troubleshooting unless you fully understand the data impact.
Check Queue and Cache Drivers
Queue and cache misconfiguration can cause 500 errors when the request touches jobs, sessions, locks, rate limits, or cached data.
CACHE_STORE=file
QUEUE_CONNECTION=database
SESSION_DRIVER=file
If your app expects Redis but Redis is not installed, unavailable, or protected by incorrect credentials, requests can fail. Either fix Redis or switch the relevant driver to a working option for the environment.
php artisan queue:failed
php artisan queue:restart
php artisan optimize:clear
For database queues, confirm the queue table exists and migrations have run. For long-running workers, restart workers after deployment so they use the latest code and configuration.
Future internal-link opportunity: Laravel Queues Explained.
Check Web Server Configuration
Laravel should be served from the public directory. The web server should send requests to public/index.php, not expose the project root. If the server points at the project root, the app may break and sensitive files may become reachable.
Apache Issues
For Apache, confirm that the virtual host document root points to Laravel’s public directory and that rewrite support is enabled.
<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/example.com/public
<Directory /var/www/example.com/public>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
sudo a2enmod rewrite
sudo systemctl reload apache2
If routes other than the homepage fail, check that Apache is reading Laravel’s public/.htaccess file and that AllowOverride permits rewrites.
Nginx Issues
For Nginx, confirm the root points to public and the location block falls back to index.php with the query string.
server {
listen 80;
server_name example.com;
root /var/www/example.com/public;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ .php$ {
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /.(?!well-known).* {
deny all;
}
}
sudo nginx -t
sudo systemctl reload nginx
sudo systemctl restart php8.2-fpm
If Nginx returns a 500 before Laravel logs anything, the problem may be PHP-FPM, FastCGI parameters, file ownership, or Nginx configuration rather than Laravel application code.
Common Deployment Mistakes
- Deploying without a valid
.envfile. - Leaving
APP_KEYempty. - Changing
.envbut forgetting cached config. - Uploading code without running
composer install. - Running an unsupported PHP version or missing PHP extensions.
- Pointing the web server to the Laravel project root instead of
public. - Giving the web server no write access to
storageorbootstrap/cache. - Forgetting to run production migrations after a schema change.
- Using Redis, database queues, or external services in
.envbefore they are available. - Not restarting queue workers after deployment.
Future internal-link opportunity: Laravel Deployment Guide.
Step-by-Step Troubleshooting Checklist
Use this checklist when a Laravel production error needs a fast diagnosis.
- Confirm the error happens consistently and note the URL or action that triggers it.
- Check
storage/logs/laravel.logfor the newest exception. - If Laravel logs are empty, check Apache, Nginx, PHP-FPM, and system logs.
- Confirm
.envexists and contains correct production values. - Confirm
APP_KEYis present. - Run
php artisan optimize:clear. - Check write permissions for
storageandbootstrap/cache. - Run
composer install --no-dev --optimize-autoloader. - Check PHP version and extensions with
php -v,php -m, andcomposer check-platform-reqs. - Check database credentials and migration status.
- Check cache, session, and queue drivers.
- Confirm the web server document root points to
public. - Restart PHP-FPM, queue workers, and relevant services after configuration or deployment changes.
- Once fixed, rebuild production caches intentionally.
Frequently Asked Questions
Why is Laravel showing a blank white page?
A blank page usually means an error occurred while debug output is hidden or the server failed before Laravel could render a response. Check Laravel logs first, then PHP-FPM, Apache, or Nginx logs.
Should I turn on APP_DEBUG in production?
No, not publicly. Production debug mode can expose sensitive information. Use logs, staging, restricted access, or temporary private debugging instead.
What command should I run first for a Laravel 500 error?
First read the latest log entry. If the issue looks cache-related or happened after deployment, run php artisan optimize:clear.
Can a missing APP_KEY cause a 500 error?
Yes. A missing application key can break encryption-related features. Generate a key for new apps with php artisan key:generate, but do not casually rotate a production key on an existing app.
Why does Laravel still use old .env values?
Configuration may be cached. Run php artisan config:clear or php artisan optimize:clear, then rebuild production cache after confirming the fix.
What folders must Laravel be able to write to?
Laravel needs write access to storage and bootstrap/cache. Incorrect ownership or permissions on those directories commonly causes deployment errors.
Conclusion
The fastest way to fix a Laravel 500 error is to stop guessing and follow the evidence. Read the newest log entry, confirm environment values, clear stale caches, check writable directories, verify Composer dependencies, confirm PHP compatibility, and inspect database or web server configuration when the logs point there.
Most Laravel 500 errors come down to a small set of causes: missing keys, bad .env values, stale config cache, permission problems, missing packages, wrong PHP versions, database failures, unavailable services, or incorrect web server roots. Work through those in order and you will usually find the issue quickly.
FAQ
Why is Laravel showing a blank white page?
A blank page usually means an error occurred while debug output is hidden or the server failed before Laravel could render a response. Check Laravel logs first, then PHP-FPM, Apache, or Nginx logs.
Should I turn on APP_DEBUG in production?
No, not publicly. Production debug mode can expose sensitive information. Use logs, staging, restricted access, or temporary private debugging instead.
What command should I run first for a Laravel 500 error?
First read the latest log entry. If the issue looks cache-related or happened after deployment, run php artisan optimize:clear.
Can a missing APP_KEY cause a 500 error?
Yes. A missing application key can break encryption-related features. Generate a key for new apps with php artisan key:generate, but do not casually rotate a production key on an existing app.
Why does Laravel still use old .env values?
Configuration may be cached. Run php artisan config:clear or php artisan optimize:clear, then rebuild production cache after confirming the fix.
What folders must Laravel be able to write to?
Laravel needs write access to storage and bootstrap/cache. Incorrect ownership or permissions on those directories commonly causes deployment errors.
