Geekflare is supported by our audience. We may earn affiliate commissions from buying links on this site.
Share on:

How to Fix Memory Limit Error and Keep WordPress Site Going

Fix Memory Limit Error in WordPress
Invicti Web Application Security Scanner – the only solution that delivers automatic verification of vulnerabilities with Proof-Based Scanning™.

Like any other open-source solution, WordPress has pros and cons. It offers an unparalleled level of flexibility and near-limitless potential for expansion. But dealing with issues like troubleshooting errors does call for a certain degree of technical expertise. However, with the right approach, you can overcome any error and fully leverage the power of WordPress

While running your WordPress site, you can run into a typical error that says “memory limit exhausted.” This problem arises when your site uses more memory than is allowed by your server. This issue can have severe negative effects leading to a poor user experience. 

wordpress-error

It’s usual to have memory limit errors if your website receives a lot of traffic. Fortunately, there are a number of fixes that can resolve this issue, even if you are new to WordPress. This article will guide you through the process of resolving the memory limit issue of your WordPress site. Thus, you can smoothly maintain the efficiency of your site.

Common Causes Behind WordPress Memory Limit Error

Memory limit error is one of the most common errors WordPress site owners face. This type of error causes your web pages to load slowly, crash, or even become unavailable. Usually, the error says, “fatal error: allowed memory size of 67108864 bytes exhausted.” 

Let’s find the common reasons behind this error: 

Compatibility of Plugins & Themes 

WordPress plugins and themes can empower the website to incorporate novel functionalities and personalize the visual appeal. But sometimes, the plugin and theme can create compatibility issues with the WordPress version being used. Thus, it can cause various problems, including memory limit errors.

For instance, the plugin or theme can use excessive memory compared to the memory allocated by the server. To fix this issue, you can deactivate the plugin or theme causing this error. Then you can update the plugin or theme to the latest version. Plus, look for an alternative compatible with your current WordPress version. 

Huge Databases 

In WordPress, memory limit issues often arise due to the presence of large databases. As the volume of data stored on your website increases, the corresponding memory requirements for optimal operation also increase. 

database-wordpress-error

When a website undertakes extensive data querying or processing, it may surpass the assigned memory limit. As a result, the memory limit error will occur in your WordPress site. 

One solution to this issue can be eliminating extraneous data such as spam comments and post revisions. To optimize performance and memory usage, you can utilize a caching plugin that can effectively reduce the frequency of database queries. 

Resource Hungry Plugins

Using plugins that require a substantial amount of resources can potentially result in exceeding the memory limit threshold in WordPress. Such plugins necessitate significant system resources, particularly when handling substantial volumes of data or images. As a result, it can deplete the server-allocated memory limit. 

One potential solution to this issue is to disable the plugin that is consuming a significant amount of resources. Also, you can replace the plugin with one that places less strain on your server’s resources. Alternatively, you can increase the memory limit allocated to your website.  But this requires access to your website’s hosting control panel.

Inadequate Server Resources

Memory limit error is common when your WordPress site is hosted on a shared server. Shared hosting means multiple sites are hosted on the same server. This setup can result in a restricted allocation of server resources for each website.

If there is a sudden surge of traffic on your website or it’s running a resource-hungry plugin, it can surpass the allocated memory limit of the server.  Moreover, outdated hardware, inadequate disc space, and limited CPU or RAM can also lead to this error.

To resolve this issue, you can reduce the number of plugins used on your site. But if you need additional plugins to run your site’s operation, try selecting a hosting plan that gives you more memory. Upgrade to a dedicated server that offers increased resources and control over your website. 

Overloaded Website Traffic

Memory limit problems can occur when a website receives more requests than its server can handle. As a result, websites with high traffic faces the error since it requires more server resources to handle more request. 

website-traffic

High traffic also causes problems with database queries because it requires a substantial quantity of memory. Consequently, the server cannot allocate enough memory to accommodate the increased volume of queries, resulting in memory limit errors. 

To deal with it, you can improve the efficacy of your website by utilizing a content delivery network (CDN). A CDN will assist you in delivering your site’s content across different servers. So, any burden on a single server will go down. 

Moreover, using caching plugins can be useful for storing frequently assessed data. It will help you minimize the number of database queries necessary to fulfill each request. It is also essential to select a hosting plan that offers sufficient resources to accommodate your website’s traffic.

How to check the memory limit of your WordPress website

There are different methods of checking memory limits on your WordPress site. Here are some of those methods which you can easily utilize: 

#1. From WordPress Site Health

WordPress site health utility is an easy way to check your WordPress memory limit. It provides an overview of the health as well as other details, such as the PHP memory limit. 

To access the information on site health, first, go to Tools> Site Health.

wordpress-memory-error-fix

Now click the Info tab and scroll down to find the WordPress Constant option. 

Site-Health-from-Info-Tab

Click the WordPress Constants option, which will drop down the details about the parts that are loaded. 

Site-Health-Info-Atanu-Das-WordPress

Here you will get the info related to your WP_MEMORY_LIMIT, which defines the memory limit. 

Site Health Info PHP Memory Limit WordPress

If the allocated memory limit is insufficient or less than 32M, you need to increase the memory. There are multiple methods to increase this memory limit which we will discuss shortly. 

#2. Exploring the wp‑config.php file

You can also view the WordPress memory limit by opening the wp-config.php file. To get the file, you need to locate the root directory of your WordPress site. Thus, you can install a simple WordPress file management plugin in your dashboard named File Manager. 

After installing and activating the plugin, click the WP File Manager and click the first option to open the file list. 

WP File Manager wp config php file

From the list of files, right-click on wp-config.php and then click open on code editor. Now find the code – define(‘WP_MEMORY_LIMIT’, ‘256M’);. This code defines the maximum amount of memory allocated to your WordPress site. 

WP-File-Manager Memory Limit setting

The memory limit in this example is set to 256 MB, which can be modified. Keep in mind that this file must be added to the location pointed in the image. If the line is not present in the wp-config.php file, you can manually add it. But don’t forget to Save the changes before leaving. 

#3. WordPress Hosting Account 

You can always check your WordPress memory limit from the WordPress site’s hosting account or cPanel. First, log in to your hosting account, log in to your cPanel, and click on File Manager. 

cPanel File Manager

Now double-click on public_html, which will open the file list.

cPanel File Manager Public html file

In this file list, you will get the wp-config.php file which you can view and even edit.

WpConfig.php file

Now, Right-click and view the file to check the memory limit of your WordPress site. 

Memory Limit on C Panel

If you cannot find your site’s WordPress memory limit, we recommend you contact your hosting provider. They will be able to provide you with the current WordPress memory limit and PHP limit of your site. But to accomplish this task, it is customary to initiate a support ticket or send an email to your hosting provider. 

Now that you know where to find the memory limit of your WordPress site, it’s time to learn how to increase it. 

How to Fix The WordPress Memory Limit Error 

If you are willing to fix the WordPress memory limit error, follow these step-by-step approaches: 

#1. Backup Your WordPress Site

Backing up your website data is essential before making any changes to your WordPress site. Because if something goes wrong while making changes, you can easily revert to your site’s previous state. Go through the following steps to back up your WordPress site: 

  • Use a backup plugin such as UpdraftPlus, Duplicator, Jetpack
  • Use cloud backup services such as Google Drive and Amazon S3.
  • Export the database of your WordPress site manually
  • Ask your hosting provider for backup services 

If you are using a plugin, the backup process becomes very easy since you can revert the changes anytime. Plus, with real-time and automated backups, you always save your site from sudden changes. 

#2. Edit The wp-config.php File

As we mentioned earlier, the memory limit is defined in the wp-config.php file of your site. Therefore, you should start with it first to fix the memory limit issue. Here are the steps that you can follow to edit the wp-config.php file

1. Log in to your WordPress site’s cPanel or FTP client and enter the wp-config file.

2. Add the code mentioned below before the line that says, “That’s all, stop editing!”: define(‘WP_MEMORY_LIMIT’, ‘256M’);

code to fix memory limit on wp config file

3. Before exiting, save all your changes and then refresh your site to see if the memory limit issue is fixed. 

If you still have the error, you have to try a different approach to fix it. 

#3. Edit Memory Limit In php.ini File

In case you aren’t able to fix the memory limit issue through wp-config.php, you can do it using the php.ini file. With this file, you can expand the memory limit and even configure more WordPress options. Follow these steps to configure the php.ini file: 

  • Login to your cPanel and then find the public_html folder and double-click to get in
  • In the public_html folder, you will get the php.ini file which you need to edit.
cPanel php.ini file
  • If you aren’t seeing the php.ini file within the public_html folder, you can create it. To create the php.ini file, click the File option and create one manually. 
  • Within the php.ini file, you can insert the following line of codes to change the memory limits and more. 
upload_max_filesize = 256M

post_max_size = 256M

memory_limit = 256M

file_uploads = On

upload_max_filesize = 128M

max_execution_time = 300

max_allowed_packet_size = 524288000
editing the php.ini file


Note: you only need to add the memory_limit = 256 in the file. The rest of the codes are used for different purposes. 

#4. Edit Memory Limit Using .htaccess File 

If you are still having the memory limit issue in your WordPress site, go through the following steps to resolve it:

  • Log Into your cPanel and get into the plublic_html folder  
  • Find the .htaccess file within the folder 
  • By default, the .htaccess file is not available. You can make it available by clicking the settings button wheel and selecting the Show Hidden Files box
enabling .htaccess on cPanel
  • After saving the settings, access the .htaccess file and put the following code in it:
php_value max_input_vars 5000

php_value max_execution_time 300

php_value post_max_size 128M

php_value upload_max_filesize 128M

php_value memory_limit 256M
cPanel .htaccess memory limit fixing

Note: you only need to add the php_value memory_limit 256M in the file.

#5. Contact Your Hosting Provider 

If you are still facing the memory limit issue, it’s high time you contact your hosting service provider. You should first check out the memory limit allocated by your hosting provider.  Hence, you should check out your hosting dashboard, where you can find the allocated memory limit for your site. 

If you have reached the maximum memory limit of your website, then it’s time to look out for a different hosting plan. You can ask your hosting provider about the different packages they are providing. Following that, you can upgrade to a different plan or even choose a better hosting provider. 

Some of the best hosting providers are Hostinger, Bluehost, WP Engine, HostGator, etc. Also, you can avoid the shared hosting plan and upgrade to virtual private servers (VPS) or cloud hosting. Hence, you can get more memory limits and resources for your WordPress site. 

Best Practices To Avoid Memory Limit Error In Future

As a WordPress site owner, facing the memory limit issue can be frustrating. However, there are steps you can take to avoid this issue in the future. Here are the best practices to follow and prevent this issue: 

  • Always update your WordPress site to the latest version 
  • Regularly update the plugins and theme of your site
  • Select and install lightweight themes and plugins
  • Optimize your databases routinely to remove excess data
  • Use caching plugins to minimize the frequency of database queries 
  • Utilize content delivery network (CDN) to offload server resources 
  • Upgrade to a better package provided by your hosting provider 
  • Change your hosting provider to a renowned or better one 
  • Upload uploading large files directly to your website 

Summary 

WordPress memory limit errors may seem like a daunting issue to resolve. It can create a bad user experience for the site owners and hamper the overall effectiveness of the website. But after going through this guide, you’ll be able to handle it easily and keep your website running smoothly.

You may also be interested in reading about these premium WordPress Hosting platforms for heavy-traffic websites to avoid these problems.

Thanks to our Sponsors
More great readings on WordPress
Power Your Business
Some of the tools and services to help your business grow.
  • Invicti uses the Proof-Based Scanning™ to automatically verify the identified vulnerabilities and generate actionable results within just hours.
    Try Invicti
  • Web scraping, residential proxy, proxy manager, web unlocker, search engine crawler, and all you need to collect web data.
    Try Brightdata
  • Semrush is an all-in-one digital marketing solution with more than 50 tools in SEO, social media, and content marketing.
    Try Semrush
  • Intruder is an online vulnerability scanner that finds cyber security weaknesses in your infrastructure, to avoid costly data breaches.
    Try Intruder