How to Increase the PHP Memory Limit in WordPress (wp-config.php)
If you are seeing errors such as “Allowed memory size exhausted” or your site is performing slowly, you may need to increase the PHP memory limit used by WordPress.
WordPress allows you to raise the limit by adding a simple line of code inside your wp-config.php file.
1. Edit Your wp-config.php File
The wp-config.php file is located in the root folder of your WordPress installation, usually
public_html or a subfolder containing your WordPress site.
- Log in to cPanel.
- Open File Manager.
- Navigate to your WordPress root folder.
- Locate wp-config.php.
- Right-click the file and choose Edit.
2. Add the Memory Limit Line
Inside wp-config.php, add the following line above the line that says /* That's all, stop editing! */:
define( 'WP_MEMORY_LIMIT', '256M' );
In this example, WordPress will attempt to set the PHP memory limit to 256 MB. You may increase or decrease this value depending on your website’s needs.
3. Recommended Memory Limit Values
- 64M — Minimum for small blogs
- 128M — Recommended for most themes
- 256M — For WooCommerce, builders (Elementor, Divi)
- 512M — Heavy websites with many plugins
Note: Increasing this value only works if your hosting account’s PHP limit is equal or higher. On Fast2host you can adjust the PHP memory limit in:
- cPanel → MultiPHP INI Editor
- cPanel → Select PHP Version (Options tab)
4. Verifying the Memory Limit
You can confirm the change by going to:
- WordPress Dashboard → Tools → Site Health → Info
- Or create a simple
phpinfo.phpfile
Your new memory limit should now appear under PHP memory_limit.
Optimised WordPress Hosting for Maximum Speed
Boost your website with our high-performance WordPress hosting, automatic updates, premium toolkit & built-in security.
View WordPress Hosting →