Your site was working fine yesterday. Today, a plugin update fails, the editor shows a white screen, or you see this error:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes)
That message means WordPress ran out of PHP memory. The fix is usually simple: increase the WordPress memory limit. In this tutorial, you’ll learn what the memory limit is, how to check your current limit, and five safe ways to increase the WordPress memory limit, from a one-line change in wp-config.php to your hosting control panel.
Table of Contents
What Is the WordPress Memory Limit?
Every time someone loads a page on your site, the server runs PHP code: WordPress itself, your theme and every active plugin. That code needs memory (RAM) to run. To stop one site or one script from using all of a server’s memory, PHP sets a maximum amount each script may use. This is the PHP memory limit.
WordPress adds its own setting on top of that, called WP_MEMORY_LIMIT. By default, WordPress asks for 40MB on a single site and 64MB on a multisite network. For admin tasks such as updates and image editing, it asks for more through a second setting, WP_MAX_MEMORY_LIMIT, which defaults to 256MB.
There are two limits at work, and they behave differently:
| Setting | Where it’s set | What it does |
|---|---|---|
memory_limit |
PHP (php.ini, hosting panel) | The hard ceiling. No script can use more than this. |
WP_MEMORY_LIMIT |
wp-config.php | How much memory WordPress requests for normal page loads. |
WP_MAX_MEMORY_LIMIT |
wp-config.php | How much memory WordPress requests for admin tasks. |
The important rule: WordPress can never go above PHP’s memory_limit. If your host caps PHP at 128MB, setting WP_MEMORY_LIMIT to 512MB in wp-config.php won’t help. You’d need to raise the PHP limit too.
Signs You Need to Increase the WordPress Memory Limit
You may need more memory if you see any of these:
- “Allowed memory size of … bytes exhausted” errors
- A white screen (the “white screen of death”) on the front end or in the admin
- “There has been a critical error on this website” messages, with a memory error in the log or recovery email
- Plugin or theme updates that fail partway through
- Image uploads that fail or thumbnails that don’t generate
- Page builders that won’t load or freeze in the editor
- Imports and exports that stop before finishing
These problems often appear after you install a large plugin, such as a page builder, WooCommerce or a backup plugin, or when your site grows.
How to Check Your Current Memory Limit
Before you change anything, check what you have now.
- In your WordPress dashboard, go to Tools → Site Health.
- Click the Info tab.
- Open the Server section and look for PHP memory limit. This is the hard ceiling set by your host.
- Open the WordPress Constants section and look for WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT.
Write these numbers down. You’ll use them to confirm your changes worked.
Tip: If Site Health shows a PHP memory limit of 128M or lower and you run a page builder or WooCommerce, raising it is likely to help.
5 Ways to Increase the WordPress Memory Limit
Start with Method 1. If it doesn’t change the numbers in Site Health, move on to the next method.
Before you start: Back up your site, or at least download a copy of any file you’re about to edit. A typo in wp-config.php or .htaccess can take your site offline until you fix it.
Method 1: Edit wp-config.php (Most Common Fix)
This is the standard way to increase the WordPress memory limit, and it works on most hosts.
- Connect to your site with your hosting File Manager or an SFTP client.
- Open the wp-config.php file in your site’s root folder (the same folder that contains wp-content).
- Find this line near the bottom:
/* That's all, stop editing! Happy publishing. */
- Just above that line, add:
define( 'WP_MEMORY_LIMIT', '256M' );
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
- Save the file and reload Tools → Site Health → Info.
If WP_MEMORY_LIMIT now shows 256M, you’re done. If it still shows the old value, or the PHP memory limit is lower than 256M, your host’s PHP limit is capping it. Continue to the methods below.
Common mistake: Adding the lines below the “stop editing” comment. WordPress loads its settings at that point, so anything after it is ignored.
Method 2: Use Your Hosting Control Panel (Easiest on Shared Hosting)
Most hosts let you change PHP settings without touching any files.
On cPanel hosting:
- Log in to cPanel and open Software → MultiPHP INI Editor.
- Select your domain from the dropdown.
- Find memory_limit and change it to 256M (or higher if needed).
- Click Apply.
On cPanel with CloudLinux:
- Open Software → Select PHP Version.
- Click the Options tab.
- Change memory_limit to 256M. It saves automatically.
On other hosts: Look for PHP Configuration, PHP Options or PHP Settings in your dashboard. Hostinger’s hPanel and Plesk both have one. Some managed WordPress hosts ask you to contact support instead.
This method raises the PHP ceiling, so combine it with Method 1 for the best result.
Method 3: Edit php.ini
If you run your own server (VPS or dedicated) or a local development site, you can edit PHP’s main configuration file directly.
- Find the file. The easiest way is to check Loaded Configuration File in a phpinfo page. Our guide Where Is php.ini in WordPress? explains how.
- Open php.ini and find the line that starts with
memory_limit. - Change it to:
memory_limit = 256M
- Make sure the line doesn’t start with a semicolon (
;). A semicolon turns the line into a comment. - Save the file and restart PHP so the change takes effect, for example:
sudo systemctl restart php8.3-fpm
Replace 8.3 with your PHP version. On XAMPP or MAMP, stop and start the servers from the control panel.
Method 4: Create or Edit a .user.ini File
Many shared hosts that run PHP as FastCGI or PHP-FPM read a file called .user.ini in your site’s root folder. It lets you override PHP settings for your site only.
- In your site’s root folder, create a file named exactly .user.ini (with the dot at the start), or open it if it already exists.
- Add this line:
memory_limit = 256M
- Save the file.
PHP caches this file, so changes can take up to 5 minutes to apply. If you don’t see the file in File Manager, turn on Show Hidden Files (dotfiles) in its settings.
Method 5: Edit .htaccess (Apache With mod_php Only)
If your server runs PHP as an Apache module, you can set the limit in your .htaccess file.
- Open .htaccess in your WordPress root folder.
- Add this line outside the
# BEGIN WordPressand# END WordPressmarkers:
php_value memory_limit 256M
- Save and reload your site.
⚠️ Warning: On servers that use PHP-FPM or FastCGI, this line causes a 500 Internal Server Error. If that happens, remove the line straight away and use Method 2 or Method 4 instead.
Which Method Should You Use?
| Your hosting | Best method to increase the WordPress memory limit |
|---|---|
| Shared hosting with cPanel | Method 2 (hosting panel) + Method 1 (wp-config.php) |
| Shared hosting without cPanel | Method 4 (.user.ini) + Method 1 |
| Managed WordPress hosting | Method 1, then ask support if the PHP limit is too low |
| VPS or dedicated server | Method 3 (php.ini) + Method 1 |
| Local site (XAMPP, MAMP, Local) | Method 3 (php.ini) |
How Much Memory Does WordPress Need?
There’s no single right number, but these are sensible starting points:
| Type of site | Suggested memory limit |
|---|---|
| Small blog or brochure site | 128M – 256M |
| Site with a page builder (Elementor, Divi and similar) | 256M |
| WooCommerce store | 256M – 512M |
| Large store, membership site or busy multisite | 512M or more |
More isn’t always better. A very high limit won’t make your site faster. If one badly written plugin keeps running out of memory, a bigger limit can hide the problem while it slowly uses more server resources. Raise the limit to fix the error, then look at what’s using so much memory.
How to Check That Your Changes Worked
- Go to Tools → Site Health → Info.
- Check Server → PHP memory limit and WordPress Constants → WP_MEMORY_LIMIT.
- Try the action that failed before, such as the update, upload or import.
If the numbers changed and the error is gone, you’ve successfully increased the WordPress memory limit.
What If the Memory Limit Won’t Change?
You edited the wrong file. Your server may read a different php.ini than the one you changed. Check Loaded Configuration File in phpinfo.
PHP hasn’t restarted yet. On a VPS, restart PHP-FPM or Apache. With .user.ini, wait 5 minutes.
Your host enforces a maximum. Many shared plans cap memory. If your changes don’t go above a certain number, contact your host or consider a bigger plan.
WordPress is capped by PHP. Remember, WP_MEMORY_LIMIT can’t exceed PHP’s memory_limit. Raise the PHP limit first.
The problem is a plugin, not the limit. If errors return even at 512M, a plugin or theme may have a memory leak. Deactivate plugins one at a time, or use the free Query Monitor plugin to see which component uses the most memory.
How to Use Less Memory in the First Place
Increasing the WordPress memory limit fixes the symptom. These habits reduce how much memory your site needs:
- Remove plugins you don’t use. Deactivated plugins don’t use memory, but deleting them keeps things tidy.
- Replace heavy plugins with lighter alternatives where you can.
- Use a lightweight theme. Themes packed with features you never use load extra code on every page.
- Keep PHP up to date. Newer PHP 8 versions use memory more efficiently than old ones.
- Use caching. A cached page is served without running most of WordPress, so it needs far less memory. Our guide on reducing TTFB in WordPress covers caching options.
Frequently Asked Questions
What is the default WordPress memory limit?
WordPress requests 40MB for a single site and 64MB for multisite by default, and up to 256MB for admin tasks. Your host’s PHP memory limit is usually higher and acts as the ceiling.
Is it safe to increase the WordPress memory limit?
Yes. Raising the limit to 256M or 512M is common and safe on most hosts. Always back up wp-config.php before editing it.
Why didn’t changing wp-config.php work?
Most often because your host’s PHP memory_limit is lower than the value you set. WordPress can’t exceed it. Raise the PHP limit in your hosting panel, php.ini or .user.ini.
What’s the difference between WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT?
WP_MEMORY_LIMIT applies to normal page loads. WP_MAX_MEMORY_LIMIT applies to heavier admin tasks such as updates, imports and image processing.
Will increasing the memory limit speed up my site?
No. It prevents memory errors but doesn’t make pages faster. For speed, use caching, a lightweight theme and fewer plugins.
How do I increase the WordPress memory limit without FTP?
Use your hosting control panel (MultiPHP INI Editor or PHP Options), or edit wp-config.php through your host’s File Manager in the browser.
Recommended Video Tutorials
These YouTube videos show the steps on screen:
- How to increase wp memory limit? wp-config.php, by Let’s Learn WordPress: the wp-config.php method step by step.
youtube.com/watch?v=kezTvsdl1f4
- WordPress: How to Increase PHP Memory Limit, by Ecommerce TV by Nick: raising the PHP limit on your hosting.
youtube.com/watch?v=lzdmcys8o4M
- 4 Ways to Increase WordPress Memory Limit (Beginner Guide), by WP Workshop: several methods compared.
youtube.com/watch?v=MJFo_R1noBs
- How to Increase WordPress Memory Limit via cPanel File Manager, by RackNerd: editing files in cPanel.
youtube.com/watch?v=zdoCepl4d-c
Conclusion
When WordPress runs out of memory, you’ll see white screens, failed updates or “memory exhausted” errors. The fix takes a few minutes:
- Check your current limits in Tools → Site Health → Info.
- Add WP_MEMORY_LIMIT to wp-config.php.
- Raise PHP’s memory_limit in your hosting panel, php.ini or .user.ini if needed.
- Confirm the new values in Site Health and retry the failed task.
If you increase the WordPress memory limit and errors keep coming back, look for the plugin or theme that’s using too much memory.
Don’t Want to Edit Server Files? Let Our WordPress Developers Fix It
Memory errors, failed updates and white screens often point to deeper problems: a heavy plugin, an outdated PHP version or a hosting plan that no longer fits. At Unitedtheme, we offer professional WordPress development services to find the real cause and fix it properly, from tuning PHP settings and upgrading PHP safely to replacing heavy plugins and optimizing your site for speed. Hire Unitedtheme’s expert WordPress developers and get your site running smoothly again.
Official References
- WordPress Developer Resources – Editing wp-config.php
- PHP Manual – memory_limit
- PHP Manual – .user.ini files
- cPanel Documentation – MultiPHP INI Editor
Keep Your WordPress Site Healthy, Every Month
Memory limits, PHP versions and plugins all change over time. With Unitedtheme’s WordPress care plans and retainers, our team looks after your site on an ongoing basis: updates tested safely, PHP and server health checks, performance monitoring, security, backups and bug fixes. Explore Unitedtheme’s WordPress retainer plans and let us keep your site running smoothly.




Leave a Reply