Home Blog WordPress Management Quick WordPress fix: “Allowed memory size of bytes exhausted”

Quick WordPress fix: "Allowed memory size of bytes exhausted"

Quick WordPress fix: “Allowed memory size of bytes exhausted”

If you’re seeing the “Allowed memory size of bytes exhausted” error, particularly when you’re trying to do something in the dashboard, you’re probably feeling frustrated.

This is a common WordPress error, and it can really get in the way. Maybe you’re seeing it when trying to use a certain plugin in the back end, or maybe users are emailing you complaining that something doesn’t work.

Whatever the case, your site’s functionality is damaged and you want a fix now. We have a few quick solutions to help you stop the memory exhausted error in WordPress and get your site working again.

What causes the WordPress memory exhausted error?

Every website has a particular amount of memory, or RAM, it’s able to use. This is determined by your web hosting package and how much RAM your web server has access to.

Additionally, every WordPress site has a “memory limit”, which determines how much of that RAM any one PHP script is allowed to use. If a script exceeds this memory usage limit, then you’ll see the memory exhausted error.

WordPress memory exhausted error

But what exactly causes this memory exhaustion to happen? There are a few common culprits.

1: Large plugins and themes – Resource-intensive plugins and themes and those that run complex scripts can cause this fatal error.

2: Inefficient code – Unoptimized plugins, themes, or custom code can lead to excessive memory consumption. Particularly bad code can cause a memory leak, which makes your website take up more and more memory until it crashes.

3: Large media files – Attempting to upload very large media files (images, videos, audio) can exhaust memory. You should optimize images and video before uploading them to your site.

4: High traffic – Websites experiencing a traffic surge, especially sites with poorly optimized PHP scripts, can use up too many resources for your website to handle.

While it’s often best to address the problem causing the memory exhaustion (poorly coded plugins, huge media files that need to be optimized, etc), it may be that your WordPress memory limit is set way too low.

How to fix the WordPress memory exhausted error

If you’re having the WordPress memory limit error message, there’s an easy fix: increase WordPress memory limit. Each of the methods below involves editing one of three website configuration files: wp-config.php, php.ini, and .htaccess.

Additionally, there are actually two memory limit parameters: memory_limit and max_memory_limit.

memory_limit handles the PHP memory limit on the front end (your website), while max_memory_limit handles the limit on the back end (your admin dashboard). Depending on where you’re encountering the memory limit error, you may want to increase one or both.

Before you follow any of these steps, make sure you backup your website. It’s always good practice to do this before editing any sensitive files, as one wrong change could break your site.

There are three different methods for fixing this issue. Pick the one that makes the most sense for your situation. 

Method 1: Edit wp-config.php

Most web hosts allow you to access your website files through FTP/SFTP, and this is an easy and direct way to edit your site’s files.

1: The first thing you’ll need is your FTP credentials. Your WordPress hosting provider will likely allow you to access your site through FTP. If your host uses cPanel, you can log in and look in the Files section for the FTP Accounts link. Otherwise, ask your host for your credentials.

FTP Accounts on cPanel

2: Next, you’ll need an FTP client, such as FileZilla. Install FileZilla, then open it.

3: Enter your FTP credentials (Host, Username, Password, Port) into the bar at the top and click Quickconnect.

FileZilla FTP credentials Quickconnect

Now it’s time to edit the configuration files. All three of these files can be found in the root directory of your website, which is usually where you’ll find yourself once you click Quickconnect. It may also be located in the public_html folder.

We’ll start with wp-config.php.

1: Locate wp-config.php in your website’s root directory. Right click it and click Edit. It will open in Notepad or a similar program.

Editing wp-config.php file

2: Look for the values WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT, for example: define(‘WP_MEMORY_LIMIT’, ’64M’); and define(‘WP_MAX_MEMORY_LIMIT’, ‘256M’);

3: If you can’t find these values, paste them above this line: /* That’s all, stop editing! Happy publishing. */

Define wp-memory-limit on wp-config.php

4: Increase these values by changing the number, such as ‘64M’. These values are typically doubled (64M, 128M, 256M, etc). Try increasing it by one step at a time. For example: define(‘WP_MEMORY_LIMIT’, ’64M’);

5: Save your changes and upload them to your server.

You can also use your host’s cPanel to edit the wp-config.php file. 

Most web hosts have a site management panel of some sort, and cPanel is a very common one. You can access and edit site panels through cPanel, and you don’t even need to install a client like with FTP. cPanel is accessible through your web browser.

Not all web hosts use cPanel, however. Check your host’s documentation to see if they do. If they use a custom site management panel, there may be a similar file editor tool.

Here’s how to access the file editor in cPanel.

1: Login to cPanel. If you’re not sure what your login details are, ask your web host.

2: Look in the Files section for File Manager and open it.

cPanel File Manager

3: Locate your website’s root folder (look for core files like the wp-admin and wp-content folders). It may be in a folder called public_html.

Now here’s how you can edit wp-config.php in cPanel. 

1: Locate wp-config.php in your website’s root directory. Right click it and click Edit. It will open in a new tab.

Editing wp-config.php with cPanel

2: Look for the values WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT, for example: define(‘WP_MEMORY_LIMIT’, ’64M’); and define(‘WP_MAX_MEMORY_LIMIT’, ‘256M’);

3: If you can’t find these values, paste them above this line: /* That’s all, stop editing! Happy publishing. */

Define wp-memory-limit from cPanel

4: Increase these values by changing the number, such as ‘32M’. These values are typically doubled (64M, 128M, 256M, etc). Try increasing it by one step at a time. For example: define(‘WP_MEMORY_LIMIT’, ’64M’);

5: Click Save Changes.

Method 2: Edit php.ini

Another way to fix this problem is to edit the php.ini file. Not all websites have a php.ini file, but you can create one.

If you go the FTP route, here are the steps you can take: 

1: Locate php.ini in your website’s root directory. If you don’t have one, create a file and name it php.ini. Right click the file and click Edit.

Edit php.ini

2: Look for the values memory_limit and max_memory_limit, for example: memory_limit = 64M and max_memory_limit = 256M

3: If you can’t find these values, paste them in at the bottom of the document.

php.ini memory limit

4: Increase these values by changing the number, such as ‘64M’, one step at a time. For example: memory_limit = 64M

5: Save your changes and upload them to your server.

If you’re using cPanel, here’s how to edit php.ini.

1: Locate php.ini in your website’s root directory. If you don’t have one, click the File button next to a plus icon in the top left corner, and name the file php.ini, placing it in your root directory. Right click the file and click Edit.

Editing php.ini in cPanel

2: Look for the values memory_limit and max_memory_limit, for example: memory_limit = 64M and max_memory_limit = 256M

3: If you can’t find these values, paste them in at the bottom of the document.

Memory limit on php.ini

4: Increase these values by changing the number, such as ‘64M’, one step at a time. For example: memory_limit = 64M

5: Click Save Changes.

Method 3: Edit .htaccess

The third and final method we’ll discuss here today is editing the .htaccess file. Note that only Apache servers have an .htaccess file – if you don’t see one, you probably have an NGINX server.

However, this is often a hidden file, so you’ll need to switch on a certain setting to check if you have an .htaccess file. If you don’t see .htaccess after enabling hidden files, you probably don’t have one, so just skip these steps.

1: To access this file using FTP, click Server in FileZilla’s menu bar, then click Force showing hidden files. This will allow you to see the normally-hidden .htaccess file.

Force showing hidden files on FTP FileZilla

2: Locate .htaccess in your website’s root directory. Right click the file and click Edit.

3: Look for the values php_value memory_limit and php_value max_memory_limit, for example: php_value memory_limit 64M

4: If you can’t find these values, paste them in below this line: #END WordPress

Edit php_value memory_limit with .htaccess

5: Increase these values by changing the number, such as ‘32M’, one step at a time. For example: php_value memory_limit 64M

6: Save your changes and upload them to your server.

If using cPanel, you can get to .htaccess through the File Manager. This is an Apache-only file, so if you have an NGINX server, you won’t have one. If you don’t see .htaccess after enabling hidden files, just skip these steps.

1: Click the Settings button in the top right corner and enable Show hidden files.

Show hidden file preferences on .htaccess

2: Locate .htaccess in your website’s root directory. Right click the file and click Edit.

3: Look for the values php_value memory_limit and php_value max_memory_limit, for example: php_value memory_limit 64M and php_value max_memory_limit 256M

4: If you can’t find these values, paste them in below this line: #END WordPress

Editing php_value memory_limit with .htaccess

5: Increase these values by changing the number, such as ‘64M’, one step at a time. For example: php_value memory_limit 64M

6: Click Save Changes.

And that’s all – check if the issue is fixed, and increase the memory limit one increment at a time until it works.

What if none of this fixes the error? Sometimes a plugin, theme, or line of code is using extreme amounts of memory and needs to be removed.

Otherwise, the issue is probably that your web host either does not have enough memory to allocate, or is enforcing a very low memory limit. This is common on shared hosting.

Sometimes you can contact your web host and ask them to raise the memory limit, but not all will bend their policies. If not, the only solution is to upgrade your web hosting and pick a hosting plan with more powerful options.

Memory exhausted error fixed

Now you know how to fix the WordPress memory exhausted error: by editing wp config, php.ini, and .htaccess. It’s usually a quick and easy fix that can be done through FTP or cPanel.
Hopefully, your website is up and running again properly, but if the issue can’t be fixed, you may need to upgrade your hosting. If you suspect broken code is at play, read our guide to debugging common WordPress issues.

Posted inWordPress Management
Brenda Barron
Brenda Barron

Brenda is a freelance writer with over a decade of experience with web design, development, and WordPress. When not click-clacking at the keyboard, she’s spending time with her family, playing music, or taking up a new hobby.


Leave a Reply

Your email address will not be published. Required fields are marked *

Stay in the loop

Subscribe to the Melapress newsletter and receive curated WordPress management and security tips and content.

Newsletter icon

It’s free and you can unsubscribe whenever you want. Check our blog for a taste.

Envelope icon

The survey results are in: Find out what your WordPress security gameplan might be missing

Close

The survey results are in: Find out what your WordPress security gameplan might be missing

Uploading Melapress Login Security as a zip file in WordPress
Melapress Login Security in the WordPress plugin repository
Close

Installing Melapress Login Security Free

Congratulations on taking control of your WordPress website's security by implementing robust login and password policies with Melapress Login Security. You can change your login page URL, limit failed login attempts, and reset passwords.

 

Below are two ways to install Melapress Login Security on your website:

Go to your plugin dashboard on your site, then go to "Add New" and then search for Melapress Login Security.

Download the Melapress Login Security plugin zip, then select upload in your plugin dashboard under "Add New".

OPTION 1

OPTION 2

Uploading CAPTCHA 4WP as a zip file in WordPress
CAPTCHA 4WP in the WordPress plugin repository
Close

Installing CAPTCHA 4WP Free

Well done you. You're one step closer to safeguarding your WordPress website from spam and automated attacks with CAPTCHA 4WP. You'll be able to effortlessly integrate CAPTCHA into your forms and enjoy a website with enhanced security.

 

Below are two ways to install CAPTCHA 4WP on your website:

Go to your plugin dashboard on your site, then go to "Add New", and then search for CAPTCHA 4WP.

Download the CAPTCHA 4WP plugin zip, then select upload in your plugin dashboard under "Add New".

OPTION 1

OPTION 2

Uploading WP Activity Log as a zip file in WordPress
WP Activity Log in the WordPress plugin repository
Close

Installing WP Activity Log Free on your website

You deserve a pat on the back for choosing to record user actions and changes on your website. That is the first step towards better user accountability, easier troubleshooting of website security, and many other benefits of issues.

 

Below are the two ways to install WP Activity Log on your website:

Go to your plugin dashboard on your site, then go to "Add New" and then search for WP Activity Log.

Download the WP Activity Log plugin zip, then select upload in your plugin dashboard under "Add New".

OPTION 1

OPTION 2

Uploading WP 2FA as a zip file in WordPress
WP 2FA in the WordPress plugin repository
Close

Installing WP 2FA Free

Congratulations on taking the first step towards enhancing your WordPress site's security with WP 2FA Free! You're now on your way to protecting your valuable data and ensuring peace of mind. No coding or technical knowledge is required.

 

Below are two ways to install WP 2FA on your website:

Go to your plugin dashboard on your site, then go to "Add New", and then search for WP 2FA.

Download the WP 2FA plugin zip, then select upload in your plugin dashboard under "Add New".

OPTION 1

OPTION 2