WordPress

How to Increase PHP Memory Limit in WordPress (Fast Fix)

Hit a fatal memory exhausted error? Learn how to increase PHP memory limit in WordPress using wp-config, .htaccess, or your hosting panel safely.

Maya OkaforBy Maya Okafor·October 22, 2026·How we test

Why Your WordPress Site Runs Out of PHP Memory

To increase PHP memory limit in WordPress, you must allocate additional server RAM to the PHP engine via your wp-config.php file, your .htaccess configuration, or your web hosting control panel. By default, many shared hosting providers restrict WordPress to an arbitrary memory ceiling such as 40MB or 64MB, which quickly causes crashes when heavy plugins like WooCommerce, Elementor, or multilingual suites execute complex database queries.

When a PHP script exceeds this allocated threshold, your server halts execution and logs the notorious error: 'Fatal error: Allowed memory size of bytes exhausted.' While modern web hosting architectures routinely provide gigabytes of server RAM, individual PHP processes remain throttled to protect shared environments from runaway script loops and unoptimized background queries.

Increasing this value provides immediate breathing room for bloated administrative dashboards, intensive scheduled tasks, and bulk image processing. However, raising the cap is not an infinite cure for poorly coded plugins that leak memory; it simply ensures your core software has sufficient overhead to run standard modern extensions without terminating abruptly mid-request.

Method 1: Edit wp-config.php (The Recommended Approach)

The cleanest and most reliable way to allocate more memory is by modifying your wp-config.php file, which resides in the root directory of your website. Connect to your server using SFTP or open your hosting provider's File Manager tool, locate the file, and download a local backup before making any edits.

Open wp-config.php in a plain text editor and scroll near the bottom, just above the line that says '/* That\'s all, stop editing! Happy publishing. */'. Add the code define('WP_MEMORY_LIMIT', '256M'); immediately before that line. If you are running an e-commerce store with intensive background checkout routines, you can also define('WP_MAX_MEMORY_LIMIT', '512M'); to prevent administrative cron and dashboard tasks from timing out.

Save and upload the updated file back to your server, overwriting the original copy. Verify the changes by navigating to Tools > Site Health > Info > Server inside your WordPress admin dashboard, where your PHP memory limit should now accurately reflect 256MB or the custom value you specified.

Method 2: Adjust .htaccess or php.ini on Apache and Nginx

If editing wp-config.php fails to alter the memory ceiling, your host likely enforces PHP values at the server configuration layer. For Apache and LiteSpeed web servers, you can override runtime parameters by editing the .htaccess file located inside your public root folder. Simply insert php_value memory_limit 256M at the very top of the file, making sure you do not disturb your existing WordPress rewrite directives.

On dedicated virtual private servers or setups running Nginx with PHP-FPM, you must instead adjust the system's global php.ini configuration file. Locate your active configuration by executing php --ini via SSH, locate the memory_limit directive, set it to 256M or 512M, and restart the PHP-FPM service (for instance, systemctl restart php8.2-fpm) to apply the adjustment across all workers.

Users on managed cPanel or Plesk environments can bypass configuration files entirely by utilizing the MultiPHP INI Editor or PHP Selector interface. Navigate to your hosting dashboard, choose your active domain, select the memory_limit dropdown, and toggle it to 256M or 512M before clicking Apply, which safely writes the necessary rules behind the scenes.

Troubleshooting Hard Server Limits and Common Mistakes

A frequent pitfall occurs when site owners define an arbitrary number such as 1024M in their configuration files, yet Site Health still reports an unyielding 128MB. This happens because your hosting provider dictates a hard ceiling in their master server architecture that local user-level overrides cannot surpass. If changes fail to register, your only path forward is upgrading your shared hosting plan or contacting support to lift the account cap.

Another critical mistake is confusing the frontend user limit with the administrative limit. WordPress inherently uses separate definitions for visitor requests and backend processing; setting WP_MEMORY_LIMIT alone will not automatically raise WP_MAX_MEMORY_LIMIT for bulk uploads or WooCommerce database upgrades. Always define both constants if you encounter white-screen crashes specifically inside the admin panel.

Lastly, treat persistent out-of-memory errors as symptoms rather than pure configuration issues. If your site continually exhausts 512MB on routine pageviews, use query profiling tools like Query Monitor to isolate badly indexed database calls, orphaned autoloaded options, or rogue background transients rather than repeatedly inflating memory limits until your physical server crashes.

Frequently asked

Questions readers ask about this topic

What is the recommended PHP memory limit for WordPress?

For a standard WordPress blog, 128MB is sufficient, while modern sites using page builders like Elementor or e-commerce plugins like WooCommerce require at least 256MB to avoid random crashes.

Why didn't my PHP memory limit change after editing wp-config.php?

Your web host likely enforces a hard server-level limit in their global php.ini that overrides WordPress directives. You must update the setting in your hosting control panel or ask support to raise the cap.

Can increasing the PHP memory limit slow down my website?

No, raising the limit simply increases the ceiling of available RAM that a single script can consume before terminating. It does not allocate dedicated memory permanently or slow down execution.

What is the difference between WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT?

WP_MEMORY_LIMIT controls the ceiling for frontend visitor requests, while WP_MAX_MEMORY_LIMIT controls heavy administrative tasks, dashboard actions, and background cron routines.
Keep exploring · WordPress

Where to go next on Hostilo

Newsletter

One email a month. Hosting deals, new reviews, no fluff.

Related reading