This guide teaches you step by step how to increase WordPress memory limit and maximum WordPress upload size.

Note: The methods mentioned below may or may not work on your server depending on your settings, the limitations of your hosting provider, and your settings. When in doubt, consult a WordPress technical expert.

What Is WordPress Memory Limit?

WordPress memory limit is the maximum amount of memory (RAM) that your website can use at the same time. When your site reaches the allocated memory limit, you will encounter a fatal error.

Several factors contribute to the consumption of your memory. Most notable are your own WordPress, the theme you are using, and the list of active plugins.

Generally speaking, the larger and more complex your website is, the more memory it will need.

Why do I need to increase my WP memory limit?

The default memory limit for WordPress is 32MB. This limit may be sufficient for small websites with a limited number of plugins and visitors.

However, if you need to install a fully functional demo of a premium theme, or if you have a long list of custom plugins that require installation, increasing your memory limit would be a smart move.

Basically, when you start to encounter the “Fatal Error: Out of Memory Size”, it would be a good time to make those changes.

How To Increase The WP Memory Limit?

Method 1 – Change The WP Memory Limit Using The (php.ini) File

  1. Find or locate your php.ini file. If you can not find it, then simply create your own php.ini file and place it in the root directory of your WordPress installation.
  2. Open your php.ini file then edit it using your favorite editor.
  3. Find the line: memory_limit = 32M
  4. Change the 32M or any number you find there to your desired limit (e.g. 256M).
  5. Save your changes and reboot your localhost or server.

Note 1: Many shared web hosts prevent you from accessing the php.ini file. This method is only applicable if you have direct access to your php.ini file or if you are running your WordPress on localhost. It is also good to note that this method only affects the PHP memory limit.

Note 2: If you have created your own php.ini file, you need to add the following line of code to the file: memory_limit = 256M

Method 2 – Change The WP Memory Limit Using The (wp-config.php) File

  1. Find your wp-config.php file in the root directory of your WordPress installation.
  2. Open the wp-config.php file with a text editor then locate the line that includes: define(‘WP_DEBUG’, false);
  3. Then add after it, the below line of code: define (‘WP_MEMORY_LIMIT’, ‘256M’);
  4. Save the wp-config.php file then refresh your website.

Method 3 – Change The WP Memory Limit Using The (.htaccess) File

  1. Search for your .htaccess file which should be located in the root directory of your WordPress installation. If you can’t find it then it might be hidden. Thus, make sure to check your hidden files when locating it.
  2. Open the .htaccess file with a text editor and add the following line of code:
    php_value memory_limit 256M
  3. Save the .htaccess file then refresh your website.

How To Increase Upload Max Size

Learn the details step-by-step below.

What Is Upload Max Size?

This is the maximum size allowed for a file to upload to your WordPress site. A file can be a plugin, a theme, an image, a sound, a video or any other type of file. The default size is 2MB, which is considered by many webmasters to be a very low upper limit for the allowed upload file size.

Why do I need to increase the maximum WP upload size?

If you are uploading large images, audio / video files, or plugins that exceed the default limit, you may find it easier to increase the maximum file upload size as well as the maximum size of your post, always use the FTP manager.

How To Increase WP Upload Max Size?

Method 1 – Change The Maximum File Upload Size Using The Theme (functions.php) File

  1. Open your theme files and locate the functions.php file. You can also contact your theme developer for assistance if required.
  2. Add the below code lines to the file:
    @ini_set(‘upload_max_size’ , ’64M’);
  3. Save the functions.php file then refresh your website.

Method 2 – Change The Maximum File Upload Size Using The (php.ini) File

  1. Find or locate your php.ini file. If you can not find it, then simply create your own php.ini file and place it in the root directory of your WordPress installation.
  2. Open your php.ini file then edit it using your favorite editor as follows:– Find the line of:
    upload_max_filesize = 2M
    – Change the 2M or any number you find there to your desired limit (e.g. 64M).Note: If you have created your own php.ini file, then you need to add to the file the code line below:
    upload_max_filesize = 64M
  3. Save your changes and reboot your localhost or server.

Note: Many shared hosting providers restrict you from accessing the php.ini file. This method is only applicable in case you have direct access to your php.ini file or if you are running your WordPress on localhost.

Method 3 – Change The Maximum File Upload Size Using The (.htaccess) File

  1. Search for your .htaccess file which should be located in the root directory of your WordPress installation. If you can’t find it then it might be hidden. Thus, make sure to check your hidden files when locating it.
  2. Open the .htaccess file with a text editor and add the following line of code.
    php_value upload_max_filesize 64M
  3. Save the .htaccess file then refresh your website.

Conclusion

By using one of these methods, you should have been able to increase the maximum file size to upload to WordPress.

WordPress is a commonly used CMS, around 60% of the websites in the world are built on WordPress. The plugin helps make a WordPress site more attractive and secure. But plugins can also cause a vulnerability and can be a source of malware attack. You can use various WordPress malware removal tools to help you detect malware or repair your WordPress website. There are some of the best WordPress malware scanners available that give the best result.

How do I fix my WordPress memory limit?


Increasing the WordPress Memory Limit

1. Edit your wp-config.php file.
2. Edit your PHP.ini file.
3. Edit your .htaccess file.

How do I increase my memory limit?

To increase the PHP memory limit setting, edit your PHP. ini file. Increase the default value (example: Maximum amount of memory a script may consume = 128MB) of the PHP memory limit line in php.

What is the max memory limit for php?

The PHP memory_limit is the maximum amount of server memory that each PHP script is allowed to consume.

How can I upload more than 2mb in WordPress?

Go to your WordPress Dashboard → Plugins → Add new, search “Increase Max Upload Filesize” then activate and install the plugin. Once installed, go to plugin settings and simply enter the value for upload size. Click the Save Changes button to apply the new upload size.

Categorized in: