EthioDeploy
DocsPricingDomainsBlogToolsChangelog

Blog/Fix deploy errors

Laravel 500 error after deploy

BS
Brook SolomonPublished November 15, 2026
Share on XShare on LinkedIn
500 | Server Error

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 logCauseFix
No application encryption key has been specified.APP_KEY lives in your .env, which isn't deployedSet APP_KEY as an environment variable
could not be opened in append mode: Failed to open stream: Permission deniedPHP can't write to storageGive the PHP user ownership of storage and bootstrap/cache
SQLSTATE[HY000] [2002] Connection refusedConfig cached with local database settingsCache config on the server, after env vars exist
Base table or view not found / relation "sessions" does not existMigrations never ranphp artisan migrate --force
Vite manifest not found at: .../public/build/manifest.jsonAssets were never built on the serverRun npm run build during the deploy
Class "..." not foundThe package is in require-dev and production ran composer install --no-devMove 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.1 and fails with SQLSTATE[HY000] [2002] Connection refused. Run config:cache on the server when the app starts, and php artisan config:clear to throw away a bad snapshot.
  • Code calls env() outside config files. The docs: “Once the configuration has been cached, the .env file will not be loaded; therefore, the env function will only return external, system level environment variables.” A value that only exists in a .env file comes back null.

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_KEY isn't set, the first deploy generates one and saves it to the project's environment variables, so it stays the same on later deploys.
  • storage and bootstrap/cache are owned by www-data, the user PHP-FPM runs as.
  • LOG_CHANNEL=stderr is set, so exceptions show in the Logs tab. Your own LOG_CHANNEL variable wins if you set one.
  • If package.json has a build script, it runs after composer install and the output lands in public/build.
  • config:cache, route:cache and view:cache run 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.

  • Deploy a Laravel app
  • Database addons
  • Environment variables
  • Troubleshooting deploys
Start free

Join the EthioDeploy Telegram

Release notes as they ship, plus deploy help from the team and other developers.

Join on Telegram
BS
WRITTEN BYBrook SolomonFounder, EthioDeploy

Brook Solomon founded EthioDeploy and builds its deploy pipeline, build servers and AI coding agent. The posts here come from errors seen in real deploys on the platform.

All posts by Brook →
On this page
  • Where is the real error?
  • Quick checklist
  • No application encryption key has been specified
  • Permission denied on storage or bootstrap/cache
  • Is the config cache stale?
  • Did the migrations run?
  • Vite manifest not found
  • Pages load but links and forms use http://
  • What happens on EthioDeploy?
  • Questions
  • Sources
0% read

Keep reading

  • 53300

    Fix deploy errorsNov 17, 2026

    Postgres "too many connections" after deploy: how to fix it

    Postgres refuses new connections with "FATAL: sorry, too many clients already" (SQLSTATE 53300, too_many_connections) once every slot under max_connections is taken, and max_connections defaults to 100. After a deploy the usual cause is arithmetic: each process of your app opens its own pool (10 for node-postgres and Prisma 7, 15 for SQLAlchemy), you run several processes, and for a short time the old and the new copy of the app are both connected. Count connections in pg_stat_activity, make copies × processes × pool max fit under the limit with room to spare, release clients you check out, set idle_in_transaction_session_timeout, and put PgBouncer in front when the numbers can't fit.

  • NEXT_PUBLIC_*

    Fix deploy errorsNov 17, 2026

    NEXT_PUBLIC_ env variables undefined in production: causes and fixes

    A NEXT_PUBLIC_ variable is undefined in production when it wasn't set while next build ran. Next.js replaces every process.env.NEXT_PUBLIC_ reference with a fixed value during the build, so a variable added to the server afterwards changes nothing until you build again. The other usual causes are reading it dynamically (process.env[name] or a copy of process.env), a name without the NEXT_PUBLIC_ prefix in a Client Component, and one Docker image promoted across environments. For values that must change without a rebuild, read them on the server at request time and pass them down.

  • Invalid HTTP_HOST header

    Fix deploy errorsNov 15, 2026

    Django DisallowedHost and CSRF errors behind a proxy

    DisallowedHost means the request's Host header isn't in ALLOWED_HOSTS, so Django answers 400; add your production domain to the list. The CSRF 403 "Origin checking failed - https://... does not match any trusted origins" usually means Django thinks the request came over plain HTTP: the proxy ended HTTPS and forwarded it as HTTP, so Django expects an http:// origin and the browser sent https://. Set SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https") when your proxy sets that header. Since Django 4.0, entries in CSRF_TRUSTED_ORIGINS must include the scheme, such as https://example.com.

EthioDeploy

Agentic first development and deployment, started in Ethiopia, built for developers everywhere.

Telegram community
Product
PricingAI coding agentAgent mode docsDomainsCLIFree backend hostingHosting in EthiopiaChangelog
Deploy guides
Next.jsNode.jsPythonSvelteKitTanStack StartAstroNuxtReact RouterHonoStrapiDjangoFastAPIFlaskStreamlitExpressNestJSLaravelRailsGoTelegram botDiscord botLovableBoltReplitv0Google AI StudioBase44Firebase StudioClaude Code & Cursor
Compare
vs Herokuvs Vercelvs Rendervs Railwayvs Fly.iovs Netlifyvs KoyebHeroku alternativesVercel alternativesNetlify alternativesRender alternativesRailway alternativesFly.io alternativesReplit alternativesPythonAnywhere alternativesDigitalOcean App Platform alternativesGlitch alternatives
Resources
DocsBlogFree toolsAboutSupportContactllms.txt
© 2026 EthioDeployPay by card in USD or bank transfer in ETBTermsPrivacy