How to increase the PHP memory limit and upload limit in WordPress

December 9, 2023 / WordPress

WordPress is a versatile content management platform that offers a variety of themes and plugins. With these, you can quickly create interactive and effective websites. However, if your WordPress site has extensive media content or executes long scripts, you might encounter errors such as:

  • Fatal error: Allowed memory size of 33554432 bytes exhausted
  • Fatal error: Out of memory

These errors indicate that the default memory allocation is insufficient for your WordPress code. Thankfully, resolving this issue is straightforward and does not require advanced technical expertise.

Default WordPress Memory Limit:
The default memory limit for WordPress is 32 MB, which may not suffice, especially during high-traffic or resource-intensive operations.

Methods to Increase PHP Memory Limit in WordPress:
Here are four ways to increase the PHP memory and upload limits in WordPress:

  1. Edit the wp-config.php File:
    The wp-config.php file is located in the root directory of your WordPress file system. It contains essential configuration details. To increase the memory limit:

    1. Access the file through SSH or the File Manager.
    2. Add the following line to the file:
      define('WP_MEMORY_LIMIT', '64M');
    3. You can increase this value to 128 MB if needed.
  2. Edit the php.ini File:
    If you prefer not to modify the wp-config.php file, you can adjust the php.ini file instead:

    1. Locate the file on your server, typically at /etc/php.ini (on cPanel servers).
    2. Find the line:
      memory_limit =
    3. Set the desired memory limit, for example:
      memory_limit = 64M
    4. For multiple WordPress blogs, adjust accordingly. For instance, if you have two blogs needing 64 MB each, set the limit to:
      memory_limit = 128M
  3. Edit the .htaccess File:
    The .htaccess file is a critical configuration file. When editing it:

    1. Add the following code to increase memory and upload limits:
      php_value memory_limit 256M
      
      php_value upload_max_filesize 12M
    2. Important: Always back up your .htaccess file before making changes to avoid potential corruption of your WordPress site.
  4. Contact Your Web Hosting Provider:
    If you’re not comfortable making changes yourself:

    1. Reach out to your web hosting provider for assistance.
    2. They can guide you through resolving the issue or upgrade your hosting plan to allocate more resources for your site.

Need Further Assistance?

If you have additional questions or if these solutions don’t resolve the issue, feel free to contact our support team. We’re here to help!

Spread the love