Hosting & Migration 5 min read

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

How to increase the PHP memory limit, upload size and execution time in WordPress: wp-config.php, hosting panels, php.ini, .htaccess and when to fix the real cause.

Usman Muhammad UsmanUpdated October 13, 2026
How to increase the PHP memory limit and upload size in WordPress

Messages such as ‘Allowed memory size exhausted’, ‘The uploaded file exceeds the upload_max_filesize directive’ or timeouts during imports mean WordPress has hit a PHP limit. Raising these limits is usually straightforward, but where to change them depends on your host. Here is how I adjust them, and when a higher limit only hides a bigger problem.

What PHP limits control

PHP limits protect the server from scripts using too many resources. memory_limit sets how much memory a single PHP process can use. upload_max_filesize and post_max_size limit the size of uploads. max_execution_time limits how long a script can run. max_input_vars limits how many form fields can be submitted.

WordPress has its own memory settings, WP_MEMORY_LIMIT for the front end and WP_MAX_MEMORY_LIMIT for the admin, which work within the server’s limit.

Check current limits

Go to Tools > Site Health > Info > Server to see PHP memory limit, upload size and other settings. WooCommerce users can also see them in WooCommerce > Status. The Media > Add New screen shows the maximum upload size.

Note the current values before changing anything, so you can compare after.

PHP settings
SettingControlsTypical value
memory_limitMemory per process256M to 512M
upload_max_filesizeSingle upload size64M to 128M
post_max_sizeTotal request sizeEqual or larger
max_execution_timeScript run time120 to 300 s
max_input_varsForm fields3000 to 5000

Common errors and what they mean

‘Allowed memory size of X bytes exhausted’ means a script needed more memory than allowed. ‘Exceeds the upload_max_filesize directive’ means a file is too large to upload. ‘Maximum execution time exceeded’ means a process, such as an import or backup, ran too long.

Page builder editors failing to load, menus not saving all items and imports stopping halfway are other signs of hitting limits; menu problems are often max_input_vars.

Raise WordPress memory in wp-config.php

Add a line defining WP_MEMORY_LIMIT, for example 256M, in wp-config.php above the line that says ‘That’s all, stop editing’. For the admin area, WP_MAX_MEMORY_LIMIT can be set higher. This only works up to the server’s memory_limit.

If the server limit is lower, WordPress cannot exceed it. In that case, change the server setting as described below.

Change limits in your hosting panel

Most hosts let you change PHP settings in their dashboard. In cPanel, use MultiPHP INI Editor or Select PHP Version > Options to set memory_limit, upload_max_filesize, post_max_size and max_execution_time. Managed hosts often have similar settings or support can change them.

This is the safest and most reliable method. See cPanel basics.

php.ini and .user.ini

On some hosts, you can create or edit a php.ini or .user.ini file in the site root with lines such as memory_limit = 256M and upload_max_filesize = 64M. Changes may take a few minutes to apply.

Not every host allows custom php.ini files. Check your host’s documentation.

.htaccess on Apache

On Apache servers running PHP as a module, php_value lines in .htaccess can change limits. On many modern setups using PHP-FPM, these lines cause a server error instead. Test carefully and remove the lines if the site breaks.

Prefer the hosting panel or .user.ini methods where available.

Upload size: both settings matter

To upload larger files, increase both upload_max_filesize and post_max_size, with post_max_size equal to or larger than upload_max_filesize. Memory limit should also be comfortably above them.

For very large files, such as videos, consider uploading via SFTP or using a dedicated video host rather than the media library.

Execution time for imports and backups

Long imports, migrations and backups may need a higher max_execution_time, such as 300 seconds. Many plugins process work in batches to avoid timeouts. If timeouts continue, use command-line tools such as WP-CLI, which are not limited in the same way.

Background processing through cron or Action Scheduler also avoids long single requests.

When higher limits hide a problem

If a site needs very high memory for normal pages, something is usually wrong: a heavy plugin, inefficient queries, a memory leak or too many plugins loading on every page. Raising the limit treats the symptom, not the cause.

Use Query Monitor to see memory usage per page and identify heavy plugins. See plugin bloat audit.

Typical sensible values

For most business sites, a memory limit of 256M is plenty, with stores and page builder sites sometimes needing 512M in the admin. Upload sizes of 64M to 128M suit most needs. Execution time of 120 to 300 seconds handles typical imports.

Higher values are not harmful on capable servers, but on shared hosting your plan may cap them.

After changing limits

Check Site Health again to confirm the new values. Retry the action that failed. If nothing changed, the setting may be overridden elsewhere or the host may cap it; ask support.

If the site shows a server error after editing a file, revert the change immediately using the backup copy you made.

Getting help

Adjusting server settings and fixing the underlying causes are part of my website protection service and speed optimization work.

For critical error messages, see fixing the WordPress critical error. For PHP versions, read upgrading PHP.

Key takeaways

  • Check current limits in Site Health before changing anything.
  • Use your hosting panel to change PHP settings where possible.
  • Raise both upload_max_filesize and post_max_size for larger uploads.
  • If normal pages need huge memory, find the heavy plugin causing it.

Frequently asked questions

What memory limit does WordPress need?

128M is the minimum often recommended; 256M suits most business sites.

Why did my wp-config.php change not work?

The server's memory_limit may be lower. Change it in the hosting panel.

Why can't I upload large files?

upload_max_filesize or post_max_size is too low.

Why do my menus not save all items?

Often max_input_vars is too low. Increase it in PHP settings.

Can I break my site changing these settings?

Incorrect .htaccess lines can cause errors. Keep a backup and revert if needed.

Does a higher memory limit make my site faster?

No. It prevents errors but does not speed up pages.

Do Shopify or Wix have PHP limits?

No. Hosted platforms manage servers for you, so these settings only apply to self-hosted sites such as WordPress.

Free website audit

Get a free audit of your website

Tell me your URL and I'll send a short, prioritized list of the speed, SEO and security fixes that will make the biggest difference.

  • No obligation, no sales call
  • 5.0 rating on Google and Upwork
  • Reply within one business day
Written by Muhammad UsmanWeb Development Team Lead with 5+ years building WordPress, WooCommerce, Shopify and Wix websites. Experience · Certificates About me

More on Hosting & Migration

All Hosting & Migration articles

Have a project in mind?

Tell me what you're building and I'll reply with next steps and an estimate.