Laravel 500 error: find the real cause and fix it
Published December 1, 2026 · Updated December 3, 2026
A Laravel 500 error means an exception reached the framework's handler and nobody caught it. In production, with APP_DEBUG=false, Laravel shows a generic "Server Error" page and writes the real exception to its log, by default storage/logs/laravel.log. Read that file first: the class, the message and the stack trace almost always name the cause.
What a 500 means in Laravel
HTTP 500 is the server saying "something went wrong on my side". In a Laravel application it nearly always comes from one of two places:
- Laravel booted and an exception was thrown: a missing table, a null where an object was expected, a view that does not compile. The exception handler reports it (writes it to the log) and renders the error page. This is the common case, and the log has the answer.
- PHP failed before Laravel could handle anything: the
vendordirectory is missing, the PHP version does not match the dependencies, a fatal error or a memory limit. Laravel never got the chance to log, so the evidence is in the PHP-FPM or web server log instead.
A 502 or 504 is a different problem: the web server could not get an answer from PHP-FPM at all (process down, timeout). Do not mix the two when you search.
Why you see a blank "Server Error" page
The debug option in config/app.php reads APP_DEBUG. With true, Laravel renders the full exception page with the stack trace and parts of your environment. The official documentation is explicit: in production APP_DEBUG must always be false, or you risk exposing sensitive configuration values to your visitors.
So do not switch debug mode on in production to "see the error". The same information is already in the log, where only you can read it.
You can replace the generic page with your own by creating resources/views/errors/500.blade.php, or publish Laravel's templates with php artisan vendor:publish --tag=laravel-errors. That changes what the visitor sees, not what gets logged.
Where the exception goes
By default, Laravel reports every exception through your logging configuration, at the error level. With the default stack channel wrapping single, that means one file:
tail -n 200 storage/logs/laravel.logIf your LOG_STACK (or LOG_CHANNEL) uses the daily channel, there is one file per day, named with the date:
ls -lt storage/logs/ | head
tail -n 200 storage/logs/laravel-$(date +%F).logLook for the entry that starts with production.ERROR: (the prefix is your environment name), then read the first line of the stack trace that points into your own code (app/, routes/, resources/views), not into vendor/.
Reporting is configured in bootstrap/app.php, in the withExceptions closure. Two settings worth knowing when you investigate:
use App\Exceptions\PaymentGatewayException;
use Illuminate\Foundation\Configuration\Exceptions;
use Psr\Log\LogLevel;
->withExceptions(function (Exceptions $exceptions): void {
// Log database failures at "critical" so a stricter channel picks them up.
$exceptions->level(\PDOException::class, LogLevel::CRITICAL);
// Extra reporting for one exception type; the default logging still happens.
$exceptions->report(function (PaymentGatewayException $e) {
// send it somewhere else as well
});
})If someone added ->stop() to a report callback, returned false from it, or listed the class in dontReport, that exception never reaches the log. Check this file when a 500 leaves no trace. Laravel also ignores 404s, CSRF 419s and a few others on purpose, as described in the error handling documentation.
The classic causes after a deployment
Most 500s that appear right after a deploy fall into a short list.
| Symptom in the log | Likely cause | Fix |
|---|---|---|
No application encryption key has been specified. | APP_KEY missing from the server's .env | Restore the production key. Only run php artisan key:generate on a fresh install: a new key makes existing encrypted data and sessions unreadable |
The stream or file ".../laravel.log" could not be opened in append mode | storage not writable by the PHP process | Fix ownership and permissions on storage and bootstrap/cache |
Please provide a valid cache path. | storage/framework/views (or cache, sessions) missing | Recreate the directories, they are not in Git by default |
A config value is null only in production | env() called outside config/ with the config cached | Move the env() call into a config file, then php artisan config:cache |
Call to undefined function or Class not found for an extension class | PHP extension missing on the server | Install it for the PHP version FPM runs |
Base table or view not found, Unknown column | Migrations not run, or one failed halfway | php artisan migrate:status, then php artisan migrate --force |
Vite manifest not found at: ... | Front-end assets not built on the server | Run your build (npm run build) during the deployment |
| Old code still runs after the deploy | OPcache serving stale files | Reload PHP-FPM after each release |
Two of these deserve a word more.
config:cache and env(). The deployment documentation warns that once configuration is cached, the .env file is no longer loaded and every env() call outside the config files returns null. A package key read with env('STRIPE_SECRET') in a controller works on your machine and breaks in production. Read it through config('services.stripe.secret') instead.
Permissions. Laravel needs to write to storage and bootstrap/cache. The owner must be the user PHP-FPM runs as (www-data on Debian and Ubuntu by default, often forge on Forge):
sudo chown -R www-data:www-data storage bootstrap/cache
sudo chmod -R ug+rwX storage bootstrap/cacheA step-by-step diagnosis
Run these on the server, from the application's directory, in this order. Each step either finds the cause or rules out a family of them.
# 1. The exception itself
tail -n 200 storage/logs/laravel.log
# 2. The environment Laravel actually sees (debug, caches, drivers)
php artisan about
# 3. Can PHP write where it must?
ls -ld storage storage/logs storage/framework/* bootstrap/cache
# 4. Are the required extensions loaded? (CLI and FPM can differ)
php -m
# 5. Is the database schema where the code expects it?
php artisan migrate:status
# 6. Rebuild every cache from the current code and .env
php artisan optimize:clear
php artisan optimizeThen reload PHP-FPM (for example sudo systemctl reload php8.4-fpm, adapted to your version) so OPcache drops the previous release, and restart your queue workers with php artisan queue:restart or php artisan reload, since they keep the old code in memory.
One trap with step 4: the php command uses the CLI configuration, which is a different php.ini from the one PHP-FPM loads. An extension present in php -m can still be missing for web requests. phpinfo() served by FPM, or the FPM configuration directory, settles it.
When there is no log at all
If laravel.log has nothing at the time of the error, the problem is upstream of Laravel's logger.
- Laravel could not write the log. A permission problem on
storage/logsmakes the logger itself fail. The resulting error goes to PHP's own error log. - The log channel is misconfigured.
LOG_CHANNEL=nulldiscards everything. ALOG_LEVELaboveerrordrops exceptions, which are logged aterrorby default. If a channel cannot be created at all, Laravel falls back to an emergency logger that writes tostorage/logs/laravel.logwith the line "Unable to create configured logger. Using emergency logger." - PHP stopped before Laravel booted. A missing
vendor/directory, a parse error, or Composer's platform check: when the server's PHP is older than your dependencies require, the response is a 500 with "Composer detected issues in your platform". A fatal error such as an exhausted memory limit also ends the process before any handler runs.
In those cases, read the logs one level down. On Debian and Ubuntu with Nginx they are usually:
sudo tail -n 100 /var/log/nginx/error.log
sudo tail -n 100 /var/log/php8.4-fpm.logPaths vary with your distribution, PHP version and pool configuration (error_log and catch_workers_output in the FPM pool). Laravel's built-in /up health route is a quick test too: it answers 200 when the application boots without an exception and 500 otherwise.
Being told before your users are
Every 500 above was visible in a file before anyone looked at it. The real problem is that nobody reads laravel.log until a customer writes in. A few ways to close that gap:
- Point an uptime check at
/up. It catches the "nothing boots" class of failures right after a deploy. - Add a
slackchannel to your stack atcriticallevel for the errors that must wake someone up. The logging guide covers channels and levels. - Report exceptions to a tracker that groups them, keeps the context and alerts on the first occurrence rather than the hundredth.
If you use Telescope to inspect requests, its production trade-offs are worth reading before you leave it enabled. And an exception thrown inside a queued job never shows a page to anyone: the queue monitoring guide covers those.
With Quiet Guard
Quiet Guard's exception tracking receives every exception your Laravel handler reports, through an additive reportable() callback that leaves your own logging untouched. Occurrences are grouped into issues by class, file and line. The issue page shows the trace like Laravel's own exception page, with the throw site first and the five lines on each side of the failing line, on up to ten frames of your own code. When the project is connected to GitHub and the release is a commit SHA (detected from a REVISION file or .git/HEAD when MONITOR_RELEASE is empty), the issue links to the commit that shipped the code. A new or reopened issue rings the dashboard bell of every member and triggers an alert on each channel you add on the project's Alerts tab: email on every plan, Slack, Discord, Teams or webhook on Solo, Indie and Studio.
composer require quiet-guard/laravel-monitorMONITOR_ENABLED=true
MONITOR_KEY=your-project-api-keyphp artisan monitor:test sends a test exception to check the connection. Details in the exception reporting documentation.
Moving from another error tracker? The Sentry, Flare and BugSnag comparison pages list the differences with their sources.
In Quiet Guard
Exception tracking
Every exception your Laravel applications throw, grouped by cause rather than by occurrence, with the full stack trace and the commit that introduced it.
Application logs
Your Laravel logs shipped as they happen, searchable by level and environment, and attached to the exception they surround.
Alerts and notifications
An alert when an issue appears or comes back, when the site goes down, when a task stops pinging or a certificate nears expiry. By email, Slack, Discord, Teams or webhook, and in the dashboard.