How to Increase the PHP Memory Limit in WordPress

· first published 2021 · canyonthemes

PHP Memory Limit

WordPress runs on PHP, and PHP only gets as much memory as your server allows each request. When a plugin, an image upload or a theme update needs more than that allowance, you see the familiar message: Allowed memory size of 41943040 bytes exhausted. The number changes; the cause is the same. This guide covers how to check your current limit and the ways to raise it, in the order you should try them.

Last updated: 2026. Tested with WordPress 6.8 and PHP 8.2–8.4.

Check your current PHP memory limit first

Before editing anything, find out what you actually have. Go to Tools > Site Health > Info and expand the Server section. You will see PHP memory limit (the server-wide value) and, under WordPress Constants, the values of WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT.

WordPress defaults WP_MEMORY_LIMIT to 40M (64M for multisite) and WP_MAX_MEMORY_LIMIT to 256M for admin screens. PHP’s own memory_limit is the ceiling; WordPress can never exceed it. If Site Health already shows 256M or more, memory is probably not your problem.

1. Modify your wp-config.php file

wp-config.php sits in your WordPress root folder (usually public_html, sometimes www or your domain name) and holds your database credentials and core constants. Connect with SFTP (FileZilla, Cyberduck) or use the file manager in your hosting panel. Most hosts have moved to SFTP; plain FTP credentials from your welcome email may no longer work.

Open the file and add this line above the comment that reads “That’s all, stop editing! Happy publishing.”:

define( 'WP_MEMORY_LIMIT', '256M' );

If you hit the limit mainly in the admin area (bulk plugin updates, large imports, Site Editor saves), raise the admin ceiling as well:

define( 'WP_MAX_MEMORY_LIMIT', '512M' );

Save, upload, then reload Site Health. If the constant shows the new value but the PHP memory limit line has not moved, your host caps memory at the server level; use one of the methods below. 256M is enough for most sites.

2. Raise the limit in php.ini or .htaccess

On shared hosting you often get a user-level php.ini (or .user.ini) in your root folder. If it exists, edit or add:

memory_limit = 256M

On Apache servers that allow it, the same thing can be done in .htaccess:

php_value memory_limit 256M

If that line produces a 500 error, your server runs PHP as FPM/FastCGI and ignores php_value; remove it and use .user.ini or the hosting panel instead.

3. Use your hosting control panel

Most panels expose PHP settings directly. In cPanel look for MultiPHP INI Editor or Select PHP Version > Options; in Plesk it is under PHP Settings. Managed WordPress hosts either fix the limit per plan or offer a toggle in their own dashboard. While you are there, make sure the site runs PHP 8.2 or newer; older versions no longer receive security fixes.

4. Reach out to your hosting provider or upgrade your plan

When the host says no

If none of the above changes the value in Site Health, the limit is hard-coded on the server. Open a support ticket and ask for 256M; reputable hosts will do this without fuss. If the answer is that your plan does not allow it, the honest options are to upgrade to a plan with more resources or to move hosts. Any tier above entry-level shared hosting should give you at least 256M. A host that refuses to allow a common, well-documented setting is telling you something about how it will handle bigger problems later.

Find what is eating the memory

Raising the limit treats the symptom. If the error keeps returning, install Query Monitor temporarily and check the peak memory per request; it usually points to one plugin, a page builder, or an oversized image being regenerated. Deactivating plugins one at a time is slower but works on any host.

Which Canyon theme fits

A lightweight theme keeps memory pressure low so that you are not raising limits to compensate for the front end. Our free themes are built without a bundled page builder and stay well under typical limits on default settings. For a blog, start with Bloge; for a company site, Business Way ships with the sections most small businesses need and nothing else.

Summary

Check Site Health, add WP_MEMORY_LIMIT to wp-config.php, fall back to php.ini or your hosting panel, and ask your host when those fail. Once the error is gone, find the plugin or process that caused it so you are not chasing the same message again after the next update.

FAQ

What PHP memory limit should WordPress have?
256M covers the majority of sites, including WooCommerce stores of modest size. Only go to 512M if a specific process such as a large import or a page builder export demands it, and remember that WordPress can never exceed the server’s own memory_limit.
Why did editing wp-config.php not change the limit?
WP_MEMORY_LIMIT only raises the amount WordPress requests; PHP’s server-level memory_limit is the ceiling. If Site Health still shows the old PHP memory limit, change it in php.ini, .user.ini, your hosting panel, or ask your host.
Does a higher memory limit make my site faster?
No. Memory limit is a cap, not an allocation. Raising it prevents a request from failing when it genuinely needs more memory but does not speed up requests that were already within the limit. For speed, look at caching, PHP 8.2+, and reducing heavy plugins.