Debug mode is wonderful while developing a Laravel app: errors open a detailed page showing the file and line, the stack trace, request data and application state. That convenience is meant for the developer, but once the site is public anyone can see the same page. Leaving APP_DEBUG=true in a production .env is one of the most common and most expensive Laravel mistakes.
What the error page reveals
Depending on the Laravel version and installed packages, a debug page can show full server paths, source code around the failure, SQL queries, request headers and cookies, session data and sometimes environment variables, which may include database, mail, SMS gateway or payment API credentials. Triggering an error is easy: send an unexpected value, omit a required parameter or hit a moment when the database is unavailable. Automated scanners do exactly this.
From information leak to code execution
In 2021 a serious vulnerability was found in Ignition, the package that renders Laravel error pages (CVE-2021-3129): sites with debug mode on and an old Ignition version could be made to run attacker code. It has been fixed, but the lesson stands. Ignition normally lives in require-dev, so deploying with composer install --no-dev removes it entirely.
Example: a school gradebook
A private school in Tashkent launches a gradebook at maktab.example.uz. On launch day the developer enables debug mode to spot errors quickly and forgets to switch it off. Weeks later a parent reports an error page full of code and password-like strings. That parent meant no harm, but a scanner may have seen the same page, so every secret has to be rotated.
How to check
php artisan about --only=environment
php artisan tinker --execute="var_dump(config('app.debug'));"
grep -E "^APP_(ENV|DEBUG)=" .env
The second command shows the value the app actually uses, the third shows what the file says. They can differ, for the reason explained below. From outside, some Ignition versions answer at /_ignition/health-check in debug mode; if it does not return 404, check the server.
Turning it off and the config:cache trap
APP_ENV=production
APP_DEBUG=false
If php artisan config:cache was run earlier, Laravel reads bootstrap/cache/config.php rather than .env, so editing the file changes nothing. Rebuild the cache and verify:
php artisan config:clear
php artisan config:cache
php artisan about --only=environment
Users will now see a plain "Server Error" page while details go to storage/logs. If you connect an error tracking service, make sure it does not receive passwords or personal data.
If debug mode was exposed
- Change the database user's password.
- Regenerate API keys for mail, SMS, payments and other services.
- Consider rotating
APP_KEY, which ends all sessions and affects encrypted data. - Search access logs for suspicious requests.
grep "_ignition" /var/log/nginx/access.log
grep -c " 500 " /var/log/nginx/access.log
Log locations vary by host; on sayt.uz hosting they are available in the ISPmanager panel. Requests to _ignition paths or bursts of 500 responses suggest deliberate probing, so also check the database for new admin accounts.
Preventing a repeat
Keep the production .env separate and never copy it from a local machine. Add a deployment step that aborts if APP_DEBUG is true. For temporary diagnostics, read the logs or use a staging copy instead of enabling debug mode. It also helps to review the production configuration after every release, not just the first one, because a single hurried hotfix is often how debug mode ends up switched on again months after launch.