display_errors has no effect on PHP behind nginx and PHP-FPM
display_errors = On in php.ini, but the page stays blankShort answer
With nginx there is no web-server PHP setting. PHP-FPM decides. Check whether a pool file locks display_errors, whether you edited the php.ini that FPM reads (not the CLI one), and whether .user.ini is still cached. Also check that nginx is not replacing the error response with its own error page.
Fix it fast
1Find out which cause you have
Ask PHP itself which value it uses when served by FPM. Put this in a temporary file in the web root, open it in the browser, and delete it afterwards.
<?php var_dump(ini_get('display_errors'), php_ini_loaded_file());2Match what you see, then jump to its fix
- 1
ini_get shows an empty string or 0 whatever you set in php.ini or with ini_set()A pool file locks the value with php_admin_value or php_admin_flagFix - 2
php -i shows display_errors On, but the browser test shows another value or another php.ini pathYou edited the php.ini the CLI reads, not the one FPM readsFix - 3
The setting works after a few minutes, or only after FPM restartsA .user.ini change is cachedFix - 4
A plain nginx 500 or custom page appears instead of the PHP error textnginx replaces the PHP error response with its own error pageFix
- 1
What does the error look like?
display_errors = On in php.ini, but the page stays blank500 Internal Server Error with no PHP message in the browser
Cause 1 of 4
A pool file locks the value with php_admin_value or php_admin_flag
1Check
Settings in the pool file override php.ini, and php_admin_value and php_admin_flag cannot be changed with ini_set().
grep -rn -E "php_(admin_)?(value|flag)\[(display_errors|error_log|log_errors)" /etc/php/8.3/fpm/pool.d/2Fix
Change the line in the pool file, or delete it, and restart FPM. For a development server set display_errors on; leave it off in production and read the log instead.
; /etc/php/8.3/fpm/pool.d/www.conf
php_flag[display_errors] = on
sudo systemctl restart php8.3-fpm3Verify
Reload the test file; ini_get now returns the new value.
curl -s http://localhost/info-test.phpConfirmed by php.net
Cause 2 of 4
You edited the php.ini the CLI reads, not the one FPM reads
1Check
PHP looks for a php-SAPI.ini file first and a php.ini after that, in the SAPI's own search path. The CLI and FPM are separate SAPIs and can load separate files.
php --ini
ls /etc/php/8.3/2Fix
Edit the php.ini whose path php_ini_loaded_file() printed in the browser test, then restart FPM so it re-reads the file.
sudo nano /etc/php/8.3/fpm/php.ini
sudo systemctl restart php8.3-fpm3Verify
Run the browser test again.
curl -s http://localhost/info-test.phpConfirmed by php.net
Cause 3 of 4
A .user.ini change is cached
1Check
PHP re-reads .user.ini files only every user_ini.cache_ttl seconds, 300 by default. The file works only with the CGI and FastCGI SAPIs, and only for settings that are not system level.
# in the browser test file
var_dump(ini_get('user_ini.cache_ttl'));2Fix
Wait for the cache time, restart FPM, or lower user_ini.cache_ttl in php.ini for development.
; php.ini (FPM)
user_ini.cache_ttl = 53Verify
Change the value, wait five seconds, run the browser test.
curl -s http://localhost/info-test.phpConfirmed by php.net
Cause 4 of 4
nginx replaces the PHP error response with its own error page
1Check
With fastcgi_intercept_errors on, any FastCGI response with a code of 300 or more goes to nginx's error_page handling. A fatal error usually returns 500, so the PHP output is dropped.
sudo nginx -T 2>/dev/null | grep -n -E "fastcgi_intercept_errors|error_page"2Fix
Turn the directive off in the PHP location while debugging, or read the error from the PHP error log instead.
location ~ \.php$ {
fastcgi_intercept_errors off;
}3Verify
Reload nginx and trigger the error again.
sudo nginx -t && sudo systemctl reload nginxConfirmed by nginx.org
How do I stop it coming back?
- In production keep display_errors off, set log_errors on and give error_log a file the FPM user can write.
- Keep one test file that prints ini_get and php_ini_loaded_file for the FPM SAPI, and remove it after use.
- Restart FPM after every php.ini or pool change.
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:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- stegnor.comMy company site: 804 pages from a Python and Jinja generator, with 15 free browser tools.
- Spotless LaundryAn on-demand laundry app: Flutter on a Laravel back end, with Firebase for live updates.
Related fixes
Back end
PHP shows a blank page and no error message
No Warning or Fatal error text, even though the script is broken
A blank page means PHP hit an error but was told not to print it.
4 causes, each with a fixServers
nginx gives up waiting for the app and returns 504
upstream timed out (110: Connection timed out) while reading response header from upstream
nginx returns 504 when the app behind it takes the request but sends nothing back within proxy_read_timeout (60 seconds by default), or when the connection cannot be opened in time.
5 causes, each with a fixServers
nginx and PHP-FPM show File not found or Primary script unknown
File not found.
PHP-FPM received a script path it could not turn into a file.
4 causes, each with a fixServers
nginx still returns 504 although the PHP script has a long time limit
upstream timed out (110: Connection timed out) while reading response header from upstream
set_time_limit() only controls PHP.
4 causes, each with a fixServers
nginx cannot open the PHP-FPM socket: Permission denied
502 Bad Gateway
nginx runs as one user and PHP-FPM creates its socket for another.
3 causes, each with a fixServers
Cookies from a PHP backend vanish behind an nginx proxy
Login works when you call the backend directly but fails through nginx
nginx forwards Set-Cookie headers from the backend unchanged, so lost cookies usually come from the cookie itself: a domain or path that does not match the public URL, or Secure and SameSite flags the browser rejects.
4 causes, each with a fix