What the message looks like
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /var/www/site/vendor/autoload_real.php on line 41Common causes
- PHP fatal error, e.g. “Allowed memory size … exhausted” or an undefined function after an update.
- Missing PHP extension after switching PHP versions.
- The application cannot write to cache, log or upload directories.
- Rewrite loop in nginx (“rewrite or internal redirection cycle”).
- Database unreachable or credentials changed.
Check
- Show recent errors in the nginx error.log
tail -n 50 /var/log/nginx/error.log - Show PHP-FPM messages from the last minutes
- Search the PHP-FPM log for fatal errors
grep -i 'fatal' /var/log/php*-fpm.log | tail -n 10 - Fetch the status code reproducibly
curl -sS -o /dev/null -w '%{http_code}\n' https://example.com/
Fix
- Read the first error at the time of the request – it names file and line.
- For memory errors raise
memory_limitin the pool or php.ini deliberately, not blanket -1. - Install missing modules (e.g.
php8.3-intl) and restart PHP-FPM. - Give the PHP-FPM user write access to cache and log directories.
- After a failed update roll back to the last working version and analyse calmly.
Typical scenario
After a plugin update, a WordPress site shows only '500 Internal Server Error'. The nginx log merely says 'FastCGI sent in stderr', with no hint of the cause. The PHP-FPM log contains 'Allowed memory size of 134217728 bytes exhausted'. First work out which log file holds the real PHP message: the path from error_log in the PHP configuration and the FPM log with catch_workers_output are usually richer than the nginx log.
FAQ
Should I turn on display_errors?
Not in production. Errors in the browser leak paths and credentials. Keep log_errors = On and read the log.
Why is there nothing in the nginx log?
Then PHP handled the error itself and only returned 500. Check the application log or the PHP-FPM log with catch_workers_output = yes.
Why do I find no hint of the error in the log?
PHP only writes when log_errors is on and error_log points to a writable file. FPM worker output also appears only with catch_workers_output = yes. If both are missing, all you see is the bare 500.
Should I switch on display_errors?
Only briefly in a test environment. In production, error messages with paths and sometimes credentials would otherwise reach the visitor's browser. It is better to read the logs or send errors to monitoring.
Is a 500 always a PHP problem?
No. Faulty rewrite rules, broken Apache .htaccess files or crashes of another backend also produce 500. The log of the layer that sets the status gives it away. With nginx and PHP it pays to look at both logs.