PHP-FPM runs, but no PHP errors show up in any log file
PHP-FPM doesn't write to error logShort answer
PHP-FPM only logs script errors when log_errors is on, and it needs a log file the pool user can write. Print log_errors and error_log through FPM itself, not the CLI. Then fix the one that is off or unwritable. Worker stdout and stderr are discarded unless catch_workers_output is yes.
Fix it fast
1Find out which cause you have
Ask PHP-FPM, not the command line, what it uses. Put this probe in the web root, request it through your web server, then delete it.
<?php // probe.php: request it in the browser, then remove it var_dump(ini_get('log_errors'), ini_get('error_log')); error_log('fpm probe line');2Match what you see, then jump to its fix
- 1
The probe prints string(1) "0" or an empty value for log_errors.log_errors is offFix - 2
error_log prints a path, but the file is missing or owned by another user.error_log points at a file the FPM user cannot writeFix - 3
You set error_log in php.ini, yet the probe prints a different path.A pool setting overrides the php.ini you editedFix - 4
Output written to stdout or stderr by a script never appears, while PHP errors do.Worker output is thrown awayFix
- 1
What does the error look like?
PHP-FPM doesn't write to error logA script fails with HTTP 500 and the error log has no matching lineerror_log() calls leave no trace in php-fpm.log
Cause 1 of 4
log_errors is off
1Check
The manual lists the default of log_errors as 0, so a php.ini that never sets it logs nothing. Compare the value the probe printed.
curl -s http://localhost/probe.php2Fix
Turn it on in the php.ini that FPM loads (phpinfo() on a page shows its path), then restart FPM.
; php.ini used by FPM
log_errors = On3Verify
Request the probe again; log_errors prints as 1.
sudo systemctl restart php8.3-fpm
curl -s http://localhost/probe.phpConfirmed by php.net
Cause 2 of 4
error_log points at a file the FPM user cannot write
1Check
The manual says the file should be writable by the web server's user. For FPM that is the user set for the pool, not your login. Try to create the file as that user.
sudo -u www-data touch /var/log/php/errors.log
ls -l /var/log/php/2Fix
Create the folder and file, and hand them to the pool user.
sudo mkdir -p /var/log/php
sudo touch /var/log/php/errors.log
sudo chown www-data:www-data /var/log/php/errors.log3Verify
The probe's error_log() line lands in the file.
curl -s http://localhost/probe.php
tail -n 3 /var/log/php/errors.logConfirmed by php.net
Cause 3 of 4
A pool setting overrides the php.ini you edited
1Check
FPM pools can pass settings with php_admin_value and php_admin_flag. The manual says those cannot be overridden by ini_set(), and they win over php.ini for that pool. Search the pool files for them.
grep -rn "error_log\|log_errors" /etc/php/8.3/fpm/2Fix
Change the value in the pool file, or remove the line so php.ini applies.
; pool file, for example www.conf
php_admin_value[error_log] = /var/log/php/errors.log
php_admin_flag[log_errors] = on3Verify
Restart FPM and rerun the probe; it shows the pool's path.
sudo systemctl restart php8.3-fpm
curl -s http://localhost/probe.phpConfirmed by php.net
Cause 4 of 4
Worker output is thrown away
1Check
The manual says that unless catch_workers_output is set, worker stdout and stderr go to /dev/null. Its default is no.
grep -rn "catch_workers_output" /etc/php/8.3/fpm/pool.d/2Fix
Enable it in the pool file. FPM then copies worker output into its main error log.
; pool file
catch_workers_output = yes3Verify
Restart FPM, run a script that writes to stderr, and read the FPM main log; the global error_log setting names it.
sudo systemctl restart php8.3-fpm
grep -rn "^error_log" /etc/php/8.3/fpm/php-fpm.confConfirmed by php.net
How do I stop it coming back?
- Set log_errors and a full error_log path on purpose in production instead of relying on defaults.
- Keep display_errors off in production and read the log instead.
- After editing any ini file, restart FPM and re-run a probe through FPM, because the CLI reads a different configuration.
- Create the log file with the pool user as owner when you provision the server.
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
Servers
display_errors has no effect on PHP behind nginx and PHP-FPM
500 Internal Server Error with no PHP message in the browser
With nginx there is no web-server PHP setting.
4 causes, each with a fixBack end
Apache returns 503 or 504 because PHP-FPM did not answer in time
Error dispatching request
Apache sent the request to PHP-FPM and gave up waiting.
3 causes, each with a fixBack end
AWS SDK for PHP cannot get credentials from the instance profile metadata server
Error retrieving credentials from the instance profile metadata server.
The SDK tries the EC2 instance metadata service when it has no valid credentials from anywhere earlier in its chain.
4 causes, each with a fixBack end
AWS SDK for PHP rejects requests: the signature is from the future
Signature not yet current: {date} is still later than {date}
AWS compares the timestamp in your signed request with its own clock.
2 causes, each with a fixBack end
CodeIgniter 4 cannot write its cache files
CodeIgniter\Cache\Exceptions\CacheException: Cache unable to write to /var/www/app/writable/cache/
CodeIgniter 4's file cache needs a cache directory that the web server can really write to.
2 causes, each with a fixBack end
CodeIgniter 3 loads the model but the property is undefined
The model name you are loading is the name of a resource that is already being used: user
CodeIgniter 3 expects a model file named like its class, with the first letter capitalised, for example User_model.php holding class User_model.
2 causes, each with a fix