Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

Laravel shows HTTP ERROR 500 and a blank page, with no message

ErrorHTTP ERROR 500 and an empty page, with no Laravel error screen

Short answer

A bare 500 means Laravel failed before it could show its own error page, and production hides details on purpose. Read the log file, not the browser. After a fresh deploy the cause is usually one of four: no .env or APP_KEY, a stale config cache, a storage or bootstrap/cache folder the web user cannot write, or a PHP version below the framework's minimum.

  • Applies to Laravel 12, PHP 8.3, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Do not turn APP_DEBUG on for a public site, because the docs warn it can expose sensitive configuration. Read the newest log lines on the server instead. They name the exception and the file.

    tail -n 50 storage/logs/laravel.log
    php artisan about
  2. 2Match what you see, then jump to its fix

    1. 1No application encryption key has been specified.There is no .env file, or APP_KEY is emptyFix
    2. 2The app worked until config:cache ran during the deploy, and changes to .env make no differenceA stale configuration cache hides your new .env valuesFix
    3. 3The log file is empty or cannot be created, and the 500 comes on every requestThe web server user cannot write to storage or bootstrap/cacheFix
    4. 4The site fails at once, and the command-line PHP is newer than the one the web server usesThe PHP that serves the site is below the framework's minimumFix

What does the error look like?

  • HTTP ERROR 500 and an empty page, with no Laravel error screen
  • No application encryption key has been specified.
  • The site works on your machine and returns 500 right after being deployed

Cause 1 of 4

There is no .env file, or APP_KEY is empty

1Check

A new Laravel project gets its .env by copying .env.example, and the .env file is not committed to source control, so a fresh server has none. Laravel needs the key option from config/app.php, which is driven by APP_KEY, before it can encrypt cookies and sessions.

ls -la .env
grep "^APP_KEY=" .env

2Fix

Create the file from the example, fill in your real values, and generate the key with the Artisan command.

cp .env.example .env
php artisan key:generate

3Verify

Reload the page. The 500 is gone, and the log shows no new exception.

grep "^APP_KEY=" .env
tail -n 5 storage/logs/laravel.log

Confirmed by laravel.com

Did this fix it?

Cause 2 of 4

A stale configuration cache hides your new .env values

1Check

Once the configuration is cached, the .env file is no longer loaded, and env() calls outside the config files return null. A database host or key that was null at caching time keeps failing.

php artisan config:show app

2Fix

Clear the cache, fix the values, and cache again only after the .env is correct. Call env() only inside config files.

php artisan config:clear
# edit .env, then
php artisan config:cache

3Verify

Run the config command again and read the values Laravel really uses, then reload the site.

php artisan config:show app

Confirmed by laravel.com

Did this fix it?

Cause 3 of 4

The web server user cannot write to storage or bootstrap/cache

1Check

Laravel writes to the storage and bootstrap/cache directories, so the user that runs the web server must be allowed to write there. Compare the owner of these folders with the user of PHP-FPM or Apache.

ls -ld storage bootstrap/cache
ps -o user= -C php-fpm8.3 | sort -u

2Fix

Give the web server user ownership, or write permission, on both directories.

sudo chown -R www-data:www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache

3Verify

Reload the site. The log file is now created and new entries appear in it.

ls -l storage/logs/

Confirmed by laravel.com

Did this fix it?

Cause 4 of 4

The PHP that serves the site is below the framework's minimum

1Check

Laravel 12 requires PHP 8.2 or newer plus a list of extensions, including mbstring, openssl, pdo, tokenizer, xml, ctype, fileinfo and curl. The command line and the web server can run different PHP versions, so test with the version your web server really uses.

php -v
php -m | grep -E "mbstring|openssl|pdo|tokenizer|xml|ctype|fileinfo|curl"

2Fix

Point the web server at a supported PHP version and install the missing extensions for that same version, then restart PHP-FPM or Apache.

sudo apt install php8.3-fpm php8.3-mbstring php8.3-xml php8.3-curl
sudo systemctl restart php8.3-fpm

3Verify

Request the site again, and check the log for new errors.

curl -I https://example.com

Confirmed by laravel.com

Did this fix it?

How do I stop it coming back?

  • Keep APP_DEBUG=false in production and read errors from the log, or from a log service, instead.
  • Make the deploy script copy or create .env, run key:generate only on first install, and run config:cache last.
  • Give the deploy user and the web server user a shared group, so new files in storage stay writable.
  • Add the framework's health route to your uptime monitor. It returns 200 when the app boots and 500 when it does not.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Back end

Laravel cannot write its log file or the storage folder

The stream or file "/var/www/app/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied

The user that runs PHP (php-fpm or Apache, often www-data) cannot write to storage or bootstrap/cache.

4 causes, each with a fix

Back end

Why a Filament panel feels slow on a Laravel server

The panel is fast on a small demo and slow once there are many resources, pages and widgets

A slow Filament panel on a server is most often running without the production caches.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.