WordPress and some plugins may require more PHP memory than the default configuration provides. In some situations, even if the memory limit has been increased at the server level, a plugin or theme may still report that the available memory is too low.
In such cases, you can define the memory limit directly within the WordPress configuration file.
Table of Contents
Before You Begin
The preferred way to modify PHP limits is through the server configuration (for example, using the .htaccess file).
However, if WordPress or a plugin does not detect the updated value, you can additionally set the memory limit in the wp-config.php file.
Step 1: Locate the wp-config.php File
Connect to your website using FTP.
Navigate to your WordPress installation directory, typically:
public_html Locate the file:
wp-config.php Step 2: Edit the Configuration File
Open the wp-config.php file for editing.
Find the line:
/* That's all, stop editing! Happy publishing. */ Add the following code above it:
define( 'WP_MEMORY_LIMIT', '256M' ); Example
Your configuration may look like this:
define( 'WP_MEMORY_LIMIT', '256M' );
/* That's all, stop editing! Happy publishing. */ Available Memory Values
You can adjust the value based on your website’s requirements.
Examples:
define( 'WP_MEMORY_LIMIT', '128M' ); define( 'WP_MEMORY_LIMIT', '256M' ); define( 'WP_MEMORY_LIMIT', '512M' ); Note: The maximum usable value may still be limited by the PHP configuration on the hosting server.
Verifying the Change
After saving the file:
- Log in to the WordPress administration panel.
- Check the plugin or theme that previously reported a memory issue.
- Verify whether the warning has disappeared.
You can also use diagnostic plugins such as Site Health or WP Server Info to confirm the current memory limit detected by WordPress.
Common Use Cases
Increasing the WordPress memory limit can help resolve issues related to:
- Large backups and migrations
- Page builders
- WooCommerce stores
- Import/export tools
- Image optimization plugins
- Resource-intensive themes and plugins
Important Notes
- Always create a backup of
wp-config.phpbefore making changes. - Incorrect modifications to the file may cause your website to stop working.
- If increasing the value in
wp-config.phphas no effect, the server’s PHP memory limit may be lower than the value you specified.
Summary
If WordPress or a plugin reports insufficient memory, you can increase the WordPress memory limit by adding the following line to the wp-config.php file:
define( 'WP_MEMORY_LIMIT', '256M' ); This instructs WordPress to use up to 256 MB of memory, provided the server configuration allows it. For best results, ensure that the PHP memory limit configured on the hosting account is equal to or higher than the value specified in wp-config.php.