How to Increase WordPress Memory Limit and Maximum File Upload Size

If you’re running a WordPress site and encounter errors like "Allowed memory size exhausted" or "The uploaded file exceeds the upload_max_filesize directive in php.ini," it might be time to increase your WordPress memory limit and file upload size. Memory allocation defines how much server memory a WordPress site can use to execute its processes, while file upload size determines the maximum size of files you can upload via the WordPress dashboard. By default, these limits may not be sufficient for resource-intensive themes, plugins, or large media files. Here’s a step-by-step guide to increasing both.

Table of Contents

Ways to Increase WordPress Memory and File Upload Size

1. Edit wp-config.php

The wp-config.php file is one of WordPress’s core files and controls many of its settings. To increase memory and upload size:

				
					define('WP_MEMORY_LIMIT', '256M');
define('WP_MAX_MEMORY_LIMIT', '512M');
				
			

2. Modify the php.ini File

The php.ini file configures PHP settings, including memory allocation and file upload size. If you have access:

				
					memory_limit = 256M
upload_max_filesize = 64M
post_max_size = 64M
				
			

3. Adjust .htaccess File

The .htaccess file is used for server configuration. You can increase memory and upload size by:

				
					php_value memory_limit 256M
php_value upload_max_filesize 64M
php_value post_max_size 64M
				
			

4. Use cPanel or Hosting Control Panel

Most hosting providers offer user-friendly interfaces to configure PHP settings:

5. Contact Your Hosting Provider

If you don’t have access to server files or the above methods fail, reach out to your hosting provider’s support team. They can adjust these limits for you.

Verifying the Changes

To confirm that the memory limit and file upload size have been updated:

				
					<?php
phpinfo();
?>
				
			

Recommended Limits

Why Increase the Memory Limit and File Upload Size?

WordPress relies on PHP for processing tasks. Insufficient memory or upload size can cause errors, crashes, or failed uploads. Common scenarios where increasing these limits is essential include:

By increasing these limits, you can improve site stability, performance, and usability.

Conclusion

Increasing the WordPress memory limit and file upload size is a simple but effective way to resolve errors and improve your site’s performance and functionality. While methods like editing wp-config.php or .htaccess work well for many users, always ensure your hosting plan supports the changes. If unsure, consult with your hosting provider to avoid potential issues. With the right configuration, your WordPress site can handle larger workloads and deliver a smoother experience to users.