Category: cPanel & Hosting • Est. reading time: 2 minutes
If you see an error like “Allowed memory size of 134217728 bytes exhausted in /your/path/script.php”, it means a PHP script tried to use more memory than your server currently allows. The setting that controls this is PHP’s memory_limit, and the fix is to raise it. How you raise it depends on how your hosting is set up, so here are the common ways, easiest first.
If You Run WordPress
Add this line to your wp-config.php file, above the line that says “That’s all, stop editing”:
define( 'WP_MEMORY_LIMIT', '256M' );
For the admin area specifically, you can also add:
define( 'WP_MAX_MEMORY_LIMIT', '256M' );
In cPanel, With No Code
Open MultiPHP INI Editor, choose your domain, and raise memory_limit, for example to 256M. Save, and you are done.
On Your Own Server
Edit your php.ini file and set:
memory_limit = 256M
Then restart PHP, for example: sudo systemctl restart php-fpm.
On Hosts Running PHP as FPM or CGI
This is common today. Create or edit a .user.ini file in your site’s root folder and add:
memory_limit = 256M
Note that .user.ini changes are cached, so they can take up to about five minutes to take effect (unless you can restart PHP).
Only If Your Host Runs PHP as an Apache Module
In that one case you can add this to .htaccess:
php_value memory_limit 256M
Important: on the more common PHP-FPM or CGI setups, that line causes a 500 error instead. If it does, remove it and use .user.ini or the MultiPHP INI Editor above. And to correct an old tip: RLimitMem in .htaccess does not fix this error. It is an Apache setting for a different memory limit, so skip it.
If Raising It Does Not Help
If a healthy limit like 256M still gets exhausted, memory is not really the problem. A plugin, theme, or a script stuck in a loop is likely eating it, and raising the limit forever just hides that. If the error keeps coming back, or you are not sure which method fits your hosting, contact us at support@allydrez.com or 1-321-209-2004 and we will track down the cause.