Laravel 500 error after deploy
THE SHORT ANSWER
A Laravel 500 in production hides the real exception because APP_DEBUG is false, so start with the log, not the browser. After a first deploy the cause is usually one of five things: APP_KEY isn't set ("No application encryption key has been specified."), the web server can't write to storage or bootstrap/cache, the config cache was built with the wrong environment, migrations never ran so a table like sessions is missing, or "Vite manifest not found" because public/build is gitignored and nothing ran npm run build.
Where is the real error?
Not on the page. With APP_DEBUG=false, which Laravel's docs say production should always use, visitors get a bare 500 Server Error page and the exception goes to the log. The docs are blunt about the alternative: “If the APP_DEBUG variable is set to true in production, you risk exposing sensitive configuration values to your application's end users.”
A new app logs through the stack channel to a single file, storage/logs/laravel.log (LOG_CHANNEL=stack and LOG_STACK=single in .env.example). On a server you can reach, read the end of it:
tail -n 100 storage/logs/laravel.log
In a container that file is hard to get at and disappears on the next deploy. Laravel ships a stderr channel in config/logging.php, so set LOG_CHANNEL=stderr and the exception shows up in the platform's log viewer with everything else the container prints.
Quick checklist
| Message in the log | Cause | Fix |
|---|---|---|
No application encryption key has been specified. | APP_KEY lives in your .env, which isn't deployed | Set APP_KEY as an environment variable |
could not be opened in append mode: Failed to open stream: Permission denied | PHP can't write to storage | Give the PHP user ownership of storage and bootstrap/cache |
SQLSTATE[HY000] [2002] Connection refused | Config cached with local database settings | Cache config on the server, after env vars exist |
Base table or view not found / relation "sessions" does not exist | Migrations never ran | php artisan migrate --force |
Vite manifest not found at: .../public/build/manifest.json | Assets were never built on the server | Run npm run build during the deploy |
Class "..." not found | The package is in require-dev and production ran composer install --no-dev | Move it to require |
No application encryption key has been specified
Laravel encrypts cookies and sessions with APP_KEY, so a missing key breaks the first request. Locally the key sits in .env, and the default Laravel .gitignore excludes .env, so it never reaches the server. Generate a key and add it as an environment variable on the host:
php artisan key:generate --show # base64:J63qRTDLub5NuZvP+kb8YIorGS6qFYHKVo6u7179stY= APP_KEY=base64:... # paste the whole value, prefix included
Copy the base64: prefix too. Without it, or with a truncated value, you get a different error: Unsupported cipher or incorrect key length.
Keep the key stable once the app has users. Changing it makes existing sessions and anything you encrypted unreadable. To rotate on purpose, Laravel reads old keys from APP_PREVIOUS_KEYS, a comma-separated list, so values encrypted with them still decrypt.
Permission denied on storage or bootstrap/cache
Laravel's deployment docs: “Laravel will need to write to the bootstrap/cache and storage directories, so you should ensure the web server process owner has permission to write to these directories.” When it can't, the log write itself fails, so the error may only appear in the PHP or web server log:
The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied
Compiled Blade views go to storage/framework/views, so the same problem can show up as a file_put_contents permission error on the first page render. If those folders are missing entirely, Laravel throws Please provide a valid cache path. instead. Make the PHP-FPM user (often www-data on Debian and Ubuntu) the owner:
chown -R www-data:www-data storage bootstrap/cache chmod -R ug+rwX storage bootstrap/cache
It can break again later: running php artisan as root on the server (a cache clear, a queue worker) creates root-owned files in storage that PHP-FPM can't overwrite. Run artisan as the web user, or fix ownership afterwards.
Is the config cache stale?
Laravel's docs recommend php artisan config:cache (or optimize, which includes it) on every deploy. The cache is a snapshot: it holds the values from the environment at the moment it ran. Two things go wrong:
- It ran in the wrong place. Cached during a build step, before the host's environment variables exist, or on your laptop, the snapshot has your local database settings. Production then tries
127.0.0.1and fails withSQLSTATE[HY000] [2002] Connection refused. Runconfig:cacheon the server when the app starts, andphp artisan config:clearto throw away a bad snapshot. - Code calls
env()outside config files. The docs: “Once the configuration has been cached, the.envfile will not be loaded; therefore, theenvfunction will only return external, system level environment variables.” A value that only exists in a.envfile comes backnull.
Read environment variables in a config file and use config() everywhere else:
// config/services.php
'chapa' => [
'secret' => env('CHAPA_SECRET_KEY'),
],
// anywhere in the app
$secret = config('services.chapa.secret');Did the migrations run?
Laravel 11 and later keep sessions, cache and queued jobs in the database by default (SESSION_DRIVER=database, CACHE_STORE=database, QUEUE_CONNECTION=database in .env.example). Every web request touches the session, so on a fresh database the first page 500s on a missing table. On MySQL:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'laravel.sessions' doesn't exist
On Postgres:
SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "sessions" does not exist
Run the migrations as part of the deploy. In production migrate asks for confirmation, and the docs say: “To force the commands to run without a prompt, use the --force flag”:
php artisan migrate --force
An app still on the default SQLite connection fails differently when the file isn't there, because database/database.sqlite is never committed: Database file at path [...] does not exist. Ensure this is an absolute path to the database.
Vite manifest not found
Vite manifest not found at: /var/www/html/public/build/manifest.json
The @vite directive reads public/build/manifest.json to find your compiled CSS and JavaScript. The default Laravel .gitignore excludes /public/build, so a deploy that only runs composer install has no manifest. Build the assets on the server or in your build step:
npm ci npm run build
Also check that public/hot isn't in the repo. npm run dev writes that file, and while it exists @vite points the browser at your local dev server instead of the built files. The default .gitignore excludes it too.
Pages load but links and forms use http://
Not a 500, but it turns up on the same first deploy. Behind a proxy that terminates HTTPS, Laravel sees plain HTTP and builds http:// URLs, so the browser blocks assets as mixed content. Laravel's docs show trusting the proxy in bootstrap/app.php when you don't know its IP addresses:
->withMiddleware(function (Middleware $middleware): void {
$middleware->trustProxies(at: '*');
})Set APP_URL to the https:// address as well, so URLs built outside a request (queued mail, for example) are right.
What happens on EthioDeploy?
EthioDeploy detects Laravel from artisan and builds it on the official php-fpm image with nginx. Several of the causes above are handled in that build:
- If
APP_KEYisn't set, the first deploy generates one and saves it to the project's environment variables, so it stays the same on later deploys. storageandbootstrap/cacheare owned bywww-data, the user PHP-FPM runs as.LOG_CHANNEL=stderris set, so exceptions show in the Logs tab. Your ownLOG_CHANNELvariable wins if you set one.- If
package.jsonhas abuildscript, it runs aftercomposer installand the output lands inpublic/build. config:cache,route:cacheandview:cacherun when the container starts, after your environment variables are loaded. A changed variable takes effect on the next deploy.
Migrations don't run on their own unless the app is still on SQLite. With a MySQL or Postgres addon, set the Start command to php artisan migrate --force && ethiodeploy-start. composer install runs with --no-dev, so a class from a require-dev package won't be there. The Laravel deploy guide covers the database connection, Redis, queues and the scheduler.
Questions
Read the log, not the page. By default it's storage/logs/laravel.log; in a container set LOG_CHANNEL=stderr so exceptions appear in the platform's logs. Avoid turning APP_DEBUG on for a public site, because the error page exposes configuration values.
Run php artisan key:generate --show locally and add the whole value, including the base64: prefix, as the APP_KEY environment variable on your host. Your .env file isn't deployed, so the key in it never reaches the server.
storage and bootstrap/cache. The user PHP runs as, often www-data, needs write access to both, including the subfolders under storage/framework and storage/logs.
After php artisan config:cache, Laravel stops loading .env, so env() only returns real system environment variables. Call env() only inside config files and read values with config() everywhere else.
public/build is gitignored, so build the assets during the deploy with npm ci and npm run build. Make sure public/hot isn't committed either.
Sources
Checked on November 15, 2026:
- Laravel: Deployment
- Laravel: Configuration
- Laravel: Logging
- Laravel: Encryption
- Laravel: Migrations
- Laravel: Asset bundling (Vite)
- Laravel: Requests (trusted proxies)
- Laravel: Release notes
- laravel/laravel: .gitignore
- laravel/laravel: .env.example
- laravel/framework: MissingAppKeyException
- laravel/framework: Vite
- Monolog: StreamHandler
Push a repo. Get a URL.
Start freeJoin the EthioDeploy Telegram
Release notes as they ship, plus deploy help from the team and other developers.