Allowed memory size of 134217728 bytes exhausted. You SSH in, run php -i | grep memory_limit, and it says 512M. So which one is lying? Neither. The php command in your shell and the PHP that serves your website are usually separate processes that read separate configuration. Only one of them handles the web request.
The error message already tells you the real limit. 134217728 bytes is exactly 128M, and 268435456 would be 256M. If the byte count in the log doesn't match what php -i reports, you've already proved the web process runs with a different value. Everything below is about finding where that value comes from, then confirming it from the web side.
Why php -i is the wrong witness
php in a terminal, you get the CLI SAPI. When Nginx or Apache hands a request to PHP-FPM, the code runs under the FPM SAPI. They're the same language, but they start differently and usually load different config files.
On Debian and Ubuntu packages this split is easy to see. The CLI reads /etc/php/<version>/cli/php.ini, and FPM reads /etc/php/<version>/fpm/php.ini. If you edit the CLI file, the website never sees the change. FPM then adds layers the CLI ignores completely:
- Pool configuration. A pool is a group of FPM workers with its own user, socket, and settings. A pool file can force a value with
php_value[memory_limit]orphp_admin_value[memory_limit]. .user.inifiles. These sit in the document root or its subdirectories, and FPM and CGI read them per directory. The CLI does not.- The script itself. Code can call
ini_set('memory_limit', ...)at runtime. WordPress does this with itsWP_MEMORY_LIMITconstant.
php on your PATH might be 8.3 while the site's pool runs 8.1, so you end up reading a php.ini the site never loads. On the support desk, this split is a frequent reason someone says they already raised the limit and nothing changed. They did raise it, just for the wrong process.
| Layer | Read by CLI | Read by FPM | Can ini_set() or .user.ini override it |
|---|---|---|---|
| cli/php.ini | Yes | No | Yes |
| fpm/php.ini and fpm conf.d | No | Yes | Yes |
Pool php_value[memory_limit] | No | Yes | Yes |
Pool php_admin_value[memory_limit] | No | Yes | No |
.user.ini in the docroot | No | Yes | Yes, by ini_set() |
php_admin_value row explains a lot of confusing cases. When a pool sets memory_limit that way, no .user.ini, no WordPress constant, and no plugin can raise it. The only fix is in the pool file.
Map what the CLI and FPM each load
ls finds nothing.
BASH
# CLI side: binary, version, loaded php.ini, effective value
which php
php -v
php --ini
php -i | grep -i '^memory_limit'
# FPM side (Debian/Ubuntu layout; paths differ on control panels)
ls -d /etc/php/*/fpm 2>/dev/null
grep -Rn 'memory_limit' /etc/php/*/fpm/ 2>/dev/null
# Which FPM socket or port the web server sends this site to
grep -Rn 'fastcgi_pass' /etc/nginx/ 2>/dev/null
grep -Rn '^listen' /etc/php/*/fpm/pool.d/ 2>/dev/nullphp --ini shows which php.ini the CLI loads and which extra .ini files it scans. The php -i line prints two values, the local value and the master value. If those differ, something like a -d flag or an alias is changing the CLI value.
The recursive grep over the FPM directory catches both the FPM php.ini and any pool file that sets memory_limit. If a pool line shows php_admin_value[memory_limit] = 128M, that's probably your answer.
The fastcgi_pass and listen lines tie it all together. Match the socket path in the Nginx vhost to the listen line in a pool file. That tells you which PHP version and which pool actually serve this domain. On Apache with proxy_fcgi, look for the SetHandler line that points at the socket. On LiteSpeed, PHP usually runs as lsphp rather than FPM, so the file locations differ. The web-side check in the next section works the same way on all of them.
Ask a real web request instead
phpinfo() for this, because it exposes far more than you need.
PHP
<?php
// Temporary diagnostic file. Use an unguessable name and delete it after testing.
header('Content-Type: text/plain');
echo 'SAPI: ' . php_sapi_name() . PHP_EOL;
echo 'PHP version: ' . PHP_VERSION . PHP_EOL;
echo 'Loaded php.ini: ' . php_ini_loaded_file() . PHP_EOL;
echo 'Scanned ini files: ' . php_ini_scanned_files() . PHP_EOL;
echo 'memory_limit: ' . ini_get('memory_limit') . PHP_EOL;
echo 'user_ini.filename: ' . ini_get('user_ini.filename') . PHP_EOL;
echo 'user_ini.cache_ttl: ' . ini_get('user_ini.cache_ttl') . PHP_EOL;mlcheck-7f3a9c.php and request it with curl or a browser. Under FPM, the SAPI line should read fpm-fcgi. If the PHP version differs from what php -v showed, you've found a version mismatch. If the memory_limit here matches the byte count in your error log, you're looking at the right process.
This probe shows the value at the start of a request in that directory. It doesn't show later runtime changes. If the application calls ini_set() during the request, the value can change after the probe would have read it. For WordPress, WP_MEMORY_LIMIT in wp-config.php raises the limit at runtime only when the pool allows it. If the pool uses php_admin_value, the constant has no effect.
Remember that the probe only reports the directory it sits in. A .user.ini in a subdirectory, such as an admin folder, only applies to scripts in that directory and below. If the error only happens on one path, place the probe in that same directory.
Change the right layer, then prove it worked
php_admin_value, edit the pool file. If the value comes from fpm/php.ini, edit that file. Editing cli/php.ini again won't help. On control panels, the panel's PHP settings screen often writes to one of these layers for you. Use it rather than hand-editing files the panel might regenerate, and check the probe afterwards either way.
FPM reads php.ini and pool files at startup, so it needs a reload. A .user.ini change doesn't need a reload, but it's cached for user_ini.cache_ttl seconds, often 300. That's why .user.ini edits can seem to do nothing for a few minutes.
The steps below run in order. Test the config before reloading, because a syntax error in a pool file can stop FPM from coming back up.
BASH
# 1. Before: record the value the web request sees
curl -s 'https://example.com/mlcheck-7f3a9c.php'
# 2. After editing the FPM config: test it (binary name varies by version and distro)
sudo php-fpm8.2 -t
# 3. Reload gracefully so in-flight requests finish (service name varies)
sudo systemctl reload php8.2-fpm
# 4. After: confirm the new value from the web side
curl -s 'https://example.com/mlcheck-7f3a9c.php'
# 5. Remove the probe
rm -f /path/to/docroot/mlcheck-7f3a9c.phpcli/php.ini. A command-line import can succeed while the same import fails in the browser. If you've recently moved a site from mod_php, also check that old php_value lines in .htaccess aren't causing errors under PHP-FPM.
The practical rule: treat php -i as a report on your shell, not on your website. When memory errors don't match what you expect, convert the byte count in the log to megabytes, check which pool and PHP version serve the domain, and confirm the value through an actual web request before and after the change. If the before and after values come from the same probe on the same path, you know the fix landed where it counts.