How to increase your WordPress and PHP memory limit

May 19, 2022 / WordPress

WordPress is a powerful content management platform with features that make it easy to create a professional website or blog in just a few steps. However, WordPress’s default memory limit is often set to 32MB, which may not be enough if you add many plugins or experience a large increase in traffic.

If your WordPress site reaches this limit, you may see an error like:

Fatal error: Allowed memory size of 33554432 bytes exhausted

Many users in this situation contact their hosting provider or attempt modifications to their “.htaccess” file, which can sometimes lead to issues if not done carefully. Always back up your WordPress data before making any file changes.

Steps to Increase WordPress Memory Limit:

  1. Edit the “wp-config.php”:
    Locate the “wp-config.php” file in your WordPress installation directory. You can access it via SSH or your File Manager in cPanel. Add the following line to increase the memory limit:

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

    You can set this limit to 32MB, 40MB, 64MB, or even 128MB based on your requirements.

  2. Contact Your Hosting Provider (for Shared Hosting Users):
    If you are on a shared hosting plan, you may need to contact your hosting provider to increase the memory limit.
  3. Adjust PHP Memory Limit
    WordPress is built using PHP, so you’ll also need to increase PHP’s memory limit. If you have access to the PHP configuration file (typically php.ini), look for the memory_limit setting:

    memory_limit = 64M

    If you have multiple WordPress installations, ensure the PHP memory limit is sufficient to support all instances. For example, if you have two blogs, each requiring 64MB, set the PHP memory limit to 128MB:
    memory_limit = 128M

  4. Refresh Your Site
    After making these changes, refresh your WordPress blog to see if the memory limit error is resolved.

Following these steps should resolve memory-related issues on your WordPress site, ensuring smooth performance even as your site grows.

Spread the love