Fixing the "Allowed Memory Size Exhausted" Fatal Error When Upgrading WordPress: When attempting to upgrade WordPress, you might encounter a Fatal error like we did on one of our WordPress installs. This usually happens during automatic upgrades (via the dashboard) on sites with many posts, heavy plugins, or large themes. The error typically appears as:
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 2354671 bytes) in ../public_html/wordpress/wp-includes/http.php on line 1331

Why This Fatal Error Occurs
This error occurs because your WordPress site has reached the PHP memory limit set by your server configuration. Upgrades, large plugins, or complex themes can require more memory than the default allowance, causing WordPress to fail mid-upgrade.
How to Fix the Memory Exhausted Fatal Error
Follow these steps to increase the PHP memory limit and complete your WordPress upgrade safely:
- Using your favorite FTP client, connect to your WordPress installation.
- Download the wp-config.php file to your desktop for editing.
- Open wp-config.php in a text editor and add the following line under the MySQL settings or above the "That's all, stop editing" comment:
define('WP_MEMORY_LIMIT', '128M');
Note: You can increase to 256M or higher if your site is very large, but confirm with your host first.
- Save the file and upload it back to your server, overwriting the old wp-config.php file.
- Return to your WordPress dashboard and retry the upgrade.
Alternative Methods to Increase PHP Memory Limit
If the wp-config.php method does not work, you can try the following options:
- php.ini: Add or edit the line
memory_limit = 128Min your site's php.ini file. - .htaccess: Add
php_value memory_limit 128Mto your .htaccess file if allowed by your hosting. - Contact Your Host: Some shared hosts restrict PHP memory settings. Ask your hosting provider to increase your memory limit temporarily.
Tips to Avoid Memory Issues During WordPress Upgrades
- Deactivate unnecessary plugins before upgrading.
- Switch to a default theme temporarily if using a heavy or custom theme.
- Backup your site (files and database) before performing upgrades.
- Upgrade plugins and themes individually if large upgrades fail.
Summary
By increasing the PHP memory limit in wp-config.php or through your server configuration, WordPress upgrades should complete without the fatal memory exhausted error. Always backup your site before performing upgrades and consider deactivating large plugins temporarily for smoother updates.