QUICK ANSWER
To increase the PHP memory limit in WordPress, add this single line to your wp-config.php file, just above the line that reads “That’s all, stop editing!”: define( ‘WP_MEMORY_LIMIT’, ‘256M’ );
This works on all major hosting providers and takes under 2 minutes. If you need a higher limit (512M or more), use the cPanel or php.ini method below.
If WordPress is showing you the error “Fatal error: Allowed memory size of X bytes exhausted” — or if you’re seeing the White Screen of Death, slow admin loading, or plugins that suddenly stop working — a low PHP memory limit is almost certainly the cause.
This guide covers 5 different methods to fix it, ordered from easiest to most technical. Pick the one that matches your hosting setup.
Table of Contents
- What is the PHP memory limit and why does it matter?
- How to check your current PHP memory limit
- Method 1: wp-config.php (recommended, 2 minutes)
- Method 2: .htaccess file
- Method 3: php.ini file
- Method 4: cPanel PHP settings
- Method 5: functions.php (last resort)
- How much memory does WordPress actually need?
- Frequently asked questions
What Is the PHP Memory Limit and Why Does It Matter?
Every time someone visits your WordPress site, PHP scripts run on your server to build the page. Your hosting server sets a maximum amount of RAM those scripts are allowed to use — this is the PHP memory limit.
When WordPress (plus your plugins and theme) tries to use more memory than that limit allows, the server stops execution and throws an error. Depending on your WordPress settings, you will see either:
- A message that says: Fatal error: Allowed memory size of 134217728 bytes exhausted
- The WordPress White Screen of Death (blank white page, no error shown)
- Slow or broken admin dashboard, especially when running updates
- Plugins that work on some pages but fail on others
The fix is straightforward: tell the server to allow more memory. WordPress recommends a minimum of 256MB for sites with multiple plugins.
How to Check Your Current PHP Memory Limit
Before making any changes, it helps to know what memory limit is currently set. There are two quick ways to check:
Option A: Check inside WordPress admin
- Log in to your WordPress dashboard
- Go to Tools > Site Health
- Click the Info tab
- Scroll down to the Server section and expand it
- Look for PHP Memory Limit — this shows your current limit
Option B: Create a quick info page (any hosting)
- Connect to your site via FTP or File Manager
- Create a new file in your site root called info.php
- Add this single line to the file:
<?php phpinfo(); ?>
- Visit https://yourdomain.com/info.php in your browser
- Search on the page for memory_limit — you will see two columns: the server default and your current value
- Delete info.php after checking — never leave this file on a live site
TIP Most shared hosting plans default to 64MB or 128MB. WordPress needs at least 256MB. High-traffic sites or WooCommerce stores often need 512MB or more.
METHOD 1: wp-config.php — Recommended for Most Users Skill level: Beginner | Time: 2 minutes
This is the fastest and most reliable method. It works on virtually every hosting provider, including shared hosting, VPS, and managed WordPress hosts.
Steps
- Connect to your site via FTP (FileZilla is free) or open File Manager in cPanel
- Navigate to your WordPress root folder — the one that contains wp-config.php, wp-login.php, and the wp-content folder
- Open wp-config.php for editing
- Find this comment line near the bottom of the file:
/* That’s all, stop editing! Happy publishing. */
- Add the following line directly ABOVE that comment:
define( ‘WP_MEMORY_LIMIT’, ‘256M’ );
- Save and upload the file
- Reload your WordPress site or admin dashboard
To allow more memory in the wp-admin area (back end)
If you also need more memory for admin tasks like running updates or imports, add this second line alongside the first:
define( ‘WP_MEMORY_LIMIT’, ‘256M’ );
define( ‘WP_MAX_MEMORY_LIMIT’, ‘512M’ );
NOTE WP_MEMORY_LIMIT controls the front end. WP_MAX_MEMORY_LIMIT controls the admin area. Set both if you are having memory issues in the dashboard during updates or plugin installs.
How to verify it worked
Go to Tools > Site Health > Info > Server and check the PHP Memory Limit value again. It should now show 256M (or whatever value you set).
METHOD 2: .htaccess File Skill level: Beginner | Time: 3 minutes
If the wp-config.php method did not work (some hosts override it), try setting the memory limit in your .htaccess file. This method works on Apache servers — the most common type for shared hosting.
Steps
- Connect via FTP or File Manager and navigate to your WordPress root folder
- Open the .htaccess file for editing
- Note: .htaccess is a hidden file. In FileZilla, go to Server > Force Showing Hidden Files to make it visible. In cPanel File Manager, tick Show Hidden Files in the settings.
- Add this line at the top of the .htaccess file, before any existing WordPress rules:
php_value memory_limit 256M
- Save the file and reload your site
NOTE This method does not work on Nginx servers (LiteSpeed and Nginx do not read .htaccess PHP directives). If your host uses Nginx, skip to Method 3 or Method 4.
METHOD 3: php.ini File Skill level: Intermediate | Time: 5 minutes
The php.ini file controls PHP settings at the server level. This method gives you the most control and works across all server types (Apache, Nginx, LiteSpeed).
Steps
- Connect via FTP or File Manager
- Check if a php.ini file already exists in your WordPress root folder
- If it exists, open it. If it does not exist, create a new blank file named php.ini
- Add or update this line:
memory_limit = 256M
- Save the file in your WordPress root folder
- You may need to restart PHP or clear your hosting cache for the change to take effect — contact your host if you are unsure how
Other useful php.ini values to set at the same time
Since you are already in the file, these additional settings prevent other common WordPress errors:
memory_limit = 256M
max_execution_time = 300
max_input_time = 300
post_max_size = 64M
upload_max_filesize = 64M
TIP On some shared hosts, php.ini changes in your root folder may not take effect. If this happens, try placing the php.ini file inside your /wp-admin/ folder as well, or use Method 4 (cPanel).
METHOD 4: cPanel PHP Settings — Easiest for cPanel Users Skill level: Beginner | Time: 2 minutes
If your hosting uses cPanel (most shared hosts do — SiteGround, Bluehost, Hostinger, GoDaddy), you can change the PHP memory limit through a graphical interface without touching any files.
Steps for cPanel MultiPHP INI Editor
- Log in to cPanel
- Scroll to the Software section and click MultiPHP INI Editor
- Select your website’s PHP version from the dropdown at the top
- Find memory_limit in the list — you can use the search box to find it quickly
- Change the value to 256M (or higher if needed)
- Click Apply — the change takes effect immediately, no file editing required
Steps for cPanel Select PHP Version (some hosts)
- In cPanel, go to Select PHP Version (also under Software)
- Click Switch to PHP Options at the top
- Find memory_limit and click the current value to edit it
- Set it to 256M and click Apply
NOTE cPanel changes take effect server-wide for your account. This is the cleanest method because it does not require editing any WordPress files.
METHOD 5: functions.php — Last Resort Only Skill level: Intermediate | Time: 3 minutes
You can add a PHP memory directive directly to your active theme’s functions.php file. This method works, but it is the least recommended — if you switch themes, the setting disappears. Use it only if all other methods have failed.
Steps
- In WordPress admin, go to Appearance > Theme File Editor (or connect via FTP)
- Open your active theme’s functions.php file
- Add this code at the very top of the file, right after the opening <?php tag:
@ini_set( ‘memory_limit’, ‘256M’ );
- Save the file
WARNING Do NOT use the Theme File Editor on a live site unless you are comfortable with PHP. A syntax error in functions.php will cause the White Screen of Death. If that happens, rename the functions.php file via FTP to restore access.
How Much PHP Memory Does WordPress Actually Need?
The right memory limit depends on what your site does. Here are the recommended values for different site types:
| Site Type | Recommended Limit | Notes |
| Basic blog or brochure site | 128M | Minimum; fine for simple sites |
| Standard site with multiple plugins | 256M | WordPress recommended minimum |
| WooCommerce store | 512M | More products = more memory needed |
| Membership site or LMS | 512M – 1024M | User-heavy features need more RAM |
| Agency or multi-plugin setup | 512M | SEO, caching, security stacked together |
TIP More memory is not always better. Setting 1024M on a shared host that only has 256M available will not help and may cause errors. Ask your host what the maximum memory limit is for your plan before going above 512M.
Frequently Asked Questions
Why is my PHP memory limit not changing after I edit wp-config.php?
Your hosting provider may have set a hard limit on the server that overrides WordPress settings. This is common on shared hosting. Try Method 3 (php.ini) or Method 4 (cPanel) instead, as these set the limit at a higher level. If none of those work, contact your host and ask them to increase the PHP memory limit for your account.
What is the difference between WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT?
WP_MEMORY_LIMIT sets the memory available to WordPress for front-end (public) page loads. WP_MAX_MEMORY_LIMIT sets the memory available inside the wp-admin dashboard, specifically for tasks like importing data, running updates, or using the media library. If your admin is slow or crashes during updates, increase WP_MAX_MEMORY_LIMIT to 512M.
Is it safe to set the PHP memory limit to 512M or 1024M?
It is safe to set high limits as long as your server actually has that memory available. On shared hosting, there is a physical maximum — usually 256M or 512M — and setting a higher value in your files will not exceed it. On VPS or dedicated servers, you can set higher limits freely. Setting a very high value on a shared plan does not cause harm, it simply gets capped at the server maximum.
My memory limit shows ‘unlimited’ in Site Health — is that correct?
Yes. Some hosting providers and server configurations set the PHP memory limit to -1, which means unlimited. WordPress displays this as ‘unlimited’ in Site Health. If your site is still showing memory exhausted errors with an unlimited limit, the issue is likely a runaway plugin consuming excessive memory — deactivate plugins one by one to find the culprit.
Which plugins use the most PHP memory?
Page builders (Elementor, Divi, WPBakery), WooCommerce, SEO plugins (Rank Math, Yoast), security plugins (Wordfence), and backup plugins (UpdraftPlus during a backup run) are the heaviest memory users. Having multiple heavy plugins active simultaneously is the most common cause of memory exhaustion on shared hosting plans.
Do I need to restart my server after changing the memory limit?
For wp-config.php and .htaccess changes, no restart is needed — the change takes effect immediately on the next page load. For php.ini changes, some servers require PHP-FPM to be reloaded. In cPanel, changes made through MultiPHP INI Editor take effect immediately with no restart needed.
Wrapping Up
Increasing the PHP memory limit in WordPress is one of the quickest fixes you can make. Start with Method 1 (wp-config.php) — it takes two minutes and works on the majority of hosting setups. If your host overrides it, move to Method 4 (cPanel) or contact your host directly.
Once you have increased the limit, go back to Tools > Site Health > Info > Server to confirm the new value is showing. If your site was previously throwing memory errors or showing a white screen, those issues should now be resolved.
