PHP memory limit errors occur when a script tries to use more memory than allowed. Common error messages include "Allowed memory size exhausted" or "Fatal error: Out of memory." Increasing the limit resolves these issues.
When You Need More Memory
- Installing or updating large plugins or themes
- Importing large amounts of content (WooCommerce products, blog posts)
- Running resource-intensive plugins (page builders, image optimisation)
- Processing large uploads or bulk operations
- Seeing "Allowed memory size of X bytes exhausted" errors
Check Your Current PHP Memory Limit
Via WordPress Site Health
- Go to Tools > Site Health > Info
- Expand Server
- Look for PHP memory limit
Via phpinfo
- Create a file called
info.phpin your web root with:<?php phpinfo(); ?> - Visit
yourdomain.com/info.php - Search for
memory_limit - Delete info.php immediately after (it exposes sensitive server info)
Method 1: MultiPHP INI Editor (Recommended)
This is the easiest and most reliable method in cPanel.
- Log in to cPanel
- Go to Software > MultiPHP INI Editor
- Select the Basic Mode tab
- Choose your domain from the dropdown
- Find memory_limit in the list
- Change the value to
256M(or512Mfor large sites) - Click Apply
Changes take effect immediately — no server restart needed.
Method 2: .htaccess File
- In cPanel File Manager, navigate to your web root (
public_html) - Enable Show Hidden Files in Settings
- Open
.htaccessand add at the top:
php_value memory_limit 256M
This method works on Apache servers. If you get a 500 error, your server may use LiteSpeed with different syntax — use Method 1 instead.
Method 3: .user.ini or php.ini
Create or edit .user.ini in your public_html directory:
memory_limit = 256M
This works on both Apache and LiteSpeed servers. Changes may take up to 5 minutes to apply.
Method 4: wp-config.php (WordPress Only)
Edit wp-config.php and add before the line that says "stop editing":
define( 'WP_MEMORY_LIMIT', '256M' );
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
WP_MEMORY_LIMITsets the limit for front-end operationsWP_MAX_MEMORY_LIMITsets the limit for admin/back-end operations
Verify the Change
After making changes, verify the new limit using the same methods described above (Site Health or phpinfo). The new value should be reflected immediately or within a few minutes.
Recommended Values
| Site Type | Recommended Limit | |---|---| | Simple blog | 128M | | Business site with plugins | 256M | | WooCommerce store | 256M–512M | | Large multisite or membership site | 512M |
Troubleshooting
- 500 Internal Server Error after change: The method you used is not compatible with your server. Revert the change and try a different method.
- Value does not change: Clear any caching (server and browser), wait 5 minutes, and check again. The
.user.inimethod can have a delay. - Host limit: On shared hosting, there may be a maximum enforced by the server. On BearHost shared plans, the maximum is typically 512M. Contact support if you need more.
- Still getting errors: The issue may not be memory. Check your error logs in cPanel > Metrics > Errors for more specific information.