Fatal error: Allowed memory size of bytes exhausted in WordPress is a common PHP issue that halts your site, often showing a white screen or “critical error” message 2025

WordPress critical error screen due to allowed memory size exhausted.

Why Increase Maximum File Upload Size Too? Addressing Critical Error Risks

Uploading big media (images, videos, themes) hits separate limits: upload_max_filesize and post_max_size. Processing large files eats memory, linking the two issues. Default upload is often 2–8MB — increase to 64–256MB for modern needs.

Understanding the potential for a critical error helps in planning your uploads effectively.

Check current limits: Media > Add New shows “Max: X MB”.

For more optimization tutorial, check WordPress Performance Optimization section

WordPress media uploader showing maximum file upload size limit

Method 1: Edit wp-config.php (Recommended No-Plugin Fix)

Access files via cPanel File Manager, FTP, or hosting file explorer. Backup first!

  1. Open wp-config.php in root folder.
  2. Add before /* That’s all, stop editing! Happy publishing. */:

define(‘WP_MEMORY_LIMIT’, ‘512M’); // General/frontend memory
define(‘WP_MAX_MEMORY_LIMIT’, ‘1024M’); // Admin/backend memory
@ini_set(‘upload_max_filesize’, ‘128M’);
@ini_set(‘post_max_size’, ‘256M’);
@ini_set(‘max_execution_time’, ‘300’);

Adding define WP_MEMORY_LIMIT in wp-config.php file editor

Save, clear cache, refresh site.

Method 2: Use a Lightweight Plugin for Quick Limits on critical error

No file editing? Install one:

  • MaxLimits – Increase Maximum Upload, Post & PHP Limits (free)
  • WP Maximum Upload File Size

Steps:

  1. Plugins > Add New > Search “MaxLimits” or “increase upload”.
  2. Install, activate.
  3. Go to settings → Set memory_limit 512M, upload_max_filesize 128M+.
  4. Save — changes apply instantly.

Ideal for beginners avoiding code.

Method 3: Edit .htaccess File (Apache Servers)

For hosts allowing .htaccess overrides:

  1. Find .htaccess in root.
  2. Add at top:

text

php_value memory_limit 512M
php_value upload_max_filesize 128M
php_value post_max_size 256M
php_value max_execution_time 300
  1. Save. If 500 error, remove lines — host may block.

Method 4: Update php.ini or Hosting Panel Settings

Best for cPanel/DirectAdmin:

  • MultiPHP INI Editor → Select domain → Set memory_limit = 512M, upload_max_filesize = 128M.
  • Or create .user.ini in root with same values.
cPanel file manager view for editing PHP settings to increase memory limit

Method 5: Contact Hosting Support for Server-Level Changes

If above fail (shared hosting caps), ask support to raise server-wide:

  • PHP memory_limit to 512M+
  • upload_max_filesize/post_max_size accordingly

Providers like SiteGround, Kinsta, Hostinger often bump easily.

Verify Your Changes and Test Safely

  1. Tools > Site Health > Info > Server → Check memory_limit.
  2. Upload large file in Media.
  3. Create phpinfo.php: <?php phpinfo(); ?> → View for confirmations.
  4. Disable plugins temporarily via FTP (rename plugins folder) if error persists.

Prevention Tips to Avoid Future Errors

  • Use lightweight themes/plugins.
  • Optimize images/databases regularly.
  • Enable WP_DEBUG in wp-config.php for logs.
  • Choose optimized hosting with higher defaults.

Conclusion

Fixing Fatal error: Allowed memory size of bytes exhausted usually takes minutes via wp-config.php or a plugin. Combine with upload size increases for seamless media handling. Test changes carefully — start conservative (256M–512M) to avoid over-allocating on shared plans.

Fixed this error? Share your before/after memory values or hosting tips in the comments!

External links references:
https://www.siteground.com/kb/fix-fatal-error-allowed-memory-size-exhausted

Posted in Web TutorialsTags:
Write a comment

Book a free consultation to discuss your Website goals and technical requirements.

Contact Information