Laravel 500 Error After Deploy and Nothing in the Logs: Fix

Your Laravel site shows a plain 500 after a deploy and storage/logs is empty? Find the real error in minutes by checking permissions, the .env file, APP_KEY, cached config and the web server log.

A Laravel 500 error right after a deploy with nothing in storage/logs/laravel.log usually means Laravel could not write its own log or cache files, or it crashed before it could boot. Look in the web server and PHP-FPM error logs first, then fix ownership of storage and bootstrap/cache, confirm the .env file and APP_KEY exist, and clear the cached config. Do not leave APP_DEBUG=true on a live site to read the error.

A generic 500 page tells you nothing, and an empty Laravel log makes it worse. The good news is that the cause is nearly always one of five things, and each one has a clear sign. This guide goes in the order that finds the cause fastest.

Step 1: Read the Logs That Are Not Laravel's

Laravel writes to storage/logs/laravel.log only after it has booted and only if it can write the file. If the crash happens earlier, or the file is not writable, that log stays empty. The error is in a different place.

Check the web server and PHP-FPM logs:

# Nginx
sudo tail -n 50 /var/log/nginx/error.log

# Apache
sudo tail -n 50 /var/log/apache2/error.log

# PHP-FPM (path depends on your PHP version)
sudo tail -n 50 /var/log/php8.3-fpm.log

Common lines you will see:

  • Permission denied on storage/logs/laravel.log or storage/framework/views: go to Step 2.
  • No application encryption key has been specified: go to Step 3.
  • Class "..." not found or vendor/autoload.php: No such file: go to Step 4.
  • Unable to read key or a missing .env message: go to Step 3.

If you use a managed host or a container platform, the same output goes to the platform's log view. Search for the first error after the deploy time, not the last one.

Step 2: Fix Permissions on storage and bootstrap/cache

This is the most common cause right after a deploy or a fresh git clone. The files were created by your deploy user or by root, but PHP runs as another user such as www-data. Laravel then cannot write logs, compiled views, sessions or cache files. One deployment guide lists this among the most common errors, and Laracasts threads show the same symptom.

First find which user runs PHP, then check who owns the folders:

ps aux | grep -E 'php-fpm|apache2|nginx' | head
ls -ld storage bootstrap/cache storage/logs

Give the web user ownership and set sane modes:

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 {} \;

Avoid chmod -R 777. It makes the folders writable by every user on the server. Fixing the owner is safer and works just as well.

Two follow-ups matter:

  • If your deploy runs as a different user each time, set the group and a default permission so new log files stay writable. A daily log file created by a CLI command run as root can lock the web user out the next day.
  • On CentOS or RHEL, SELinux can block writes even when Unix permissions are right. Check sudo ausearch -m avc -ts recent for denials, as this guide on the permission error notes.

Step 3: Check the .env File and APP_KEY

The .env file is not in Git, so a new server or a new release folder often has none. Without it, Laravel has no APP_KEY and no database settings, and every request fails.

ls -la .env
grep -E '^APP_(KEY|ENV|DEBUG|URL)=' .env

You want APP_ENV=production, APP_DEBUG=false and a non-empty APP_KEY that starts with base64:. If the key is missing on a new server, generate one:

php artisan key:generate

Be careful on an existing site. A new APP_KEY makes old encrypted cookies and sessions unreadable, so every logged-in user is signed out. Copy the old key from your previous release instead when you are moving servers.

If you use zero-downtime deploys with release folders, link a shared .env into each release. A new empty release folder that points to no .env is a classic cause of a 500 on the first request after the switch.

Step 4: Rebuild Dependencies and the Autoloader

A deploy that skips Composer, or runs it with dev packages, can crash at boot. Typical signs are vendor/autoload.php missing, or a class from a package that is only in require-dev.

composer install --no-dev --optimize-autoloader --no-interaction

Also check the PHP version. If your code or a new package needs PHP 8.2 and the server runs 8.1, you get a parse error or a Composer platform error, and nothing reaches the Laravel log. Run php -v as the same user and binary that PHP-FPM uses. The CLI and FPM often point to different versions.

Step 5: Clear Cached Config, Routes and Views

Laravel can cache config, routes, events and views for speed. Stale caches built on another machine or before the .env change cause odd 500 errors. A cached config also means Laravel stops reading .env at all, so a fixed value seems to have no effect.

php artisan optimize:clear
php artisan config:cache
php artisan route:cache
php artisan view:cache

Run these as the web user, or fix ownership afterwards. If you run them as root, the generated files in bootstrap/cache belong to root and you are back at Step 2.

Run the commands after the .env is in place, not before. Caching config while the .env is wrong bakes the wrong values in.

Step 6: See the Real Error Safely

If the logs still show nothing, you need Laravel to print the error. Do it in a safe way:

  1. Put the site in maintenance mode with php artisan down if real users are on it.
  2. Run the failing route from the command line or with curl -i https://your-site.com/path and read the response.
  3. Use php artisan about and php artisan tinker to check that the app boots and the database connects.
  4. If you must set APP_DEBUG=true, do it for a few minutes on a private or staging copy, not on the public site. A debug page can expose environment values and stack traces.

Then switch the log channel to stderr temporarily if your platform captures container output:

LOG_CHANNEL=stderr

This sends errors to the process output, where a container platform or docker logs shows them even if the log folder is not writable.

How Relia Helps

A 500 after a deploy is hard to catch when the log file itself is broken. Relia has a Composer package for PHP and Laravel apps. It reports errors and failing requests from the running app, so you do not depend on a writable storage/logs folder to know something is wrong. It joins the deploy, the failing requests and the affected users into one incident explained in plain words, and it checks after the next deploy that the fix worked. Uptime monitors on your key pages tell you when the 500 starts. You can try the live demo or start on the Free plan.

FAQ

Why does Laravel show a 500 error but nothing in the log?

Either Laravel cannot write to storage/logs, or it failed before it booted. Check the Nginx or Apache log and the PHP-FPM log, then fix the owner of storage and bootstrap/cache.

Is chmod 777 on storage safe?

No. It lets any user on the server write there. Set the owner to the web user and use 775 for folders and 664 for files instead.

Should I set APP_DEBUG=true to see the error?

Not on a public site. It can show secrets and stack traces to visitors. Use the server logs, LOG_CHANNEL=stderr or a private copy of the site.

Why did the error start only after I deployed?

A deploy changes the files, the owner, the Composer packages and often the cached config. Any of these can break boot. Compare what changed: a missing .env, a new owner, a skipped composer install or a stale cache.

For related Laravel problems, see Laravel queue jobs not processing in production and Laravel 419 Page Expired on login.

All guides