How To Increase PHP Memory Limit Through HostGator & other Hosting Platforms

The Problem

You’re building a WordPress website and get a “memory limit” error.

I find this is one of the most common errors I get when I first start building a new WordPress site through HostGator and other hosting platforms. It typically pops up after I install a plugin immediately after installing WordPress on a new domain without first manually adjusting the memory limit.

The error itself occurs because PHP is trying to process a large database record (eg, your new WordPress site) or when importing/exporting information into/from the database (eg, you creating all the new files of your WP site).

The Solution

Here is a step-by-step walkthrough of the resolution of this problem with screenshots dating from late 2022 via HostGator.

Your dashboard GUI may look slightly different than this but the steps should still be relatively similar if not the same.

Step 1. Login to cPanel & go to File Manager

Step 2. Find the ‘public_html’ folder within your File Manager

Step 3. Find the ‘wp-config.php’ file within the ‘public_html’ folder

Step 4. Right click on the ‘wp-config.php’ file and select ‘Edit’

A pop-up might appear with a warning asking you to confirm that you want to edit this file.

Just go ahead and click “Edit” to confirm.

Step 5. Increase the PHP memory with this code snippet

Find the commented out line within the wp-config.php file that says something along the lines of:

/* That’s all, stop editing! Happy publishing. */

Above that line, enter:

define( 'WP_MEMORY_LIMIT', '128M' );

This will define and increase your memory limit to 128M.

If this doesn’t work immediately you can try changing it from 128M to 256M, but really anything higher than that isn’t necessary.

Note: Some hosts enforce extremely low memory limits to keep account costs down so you may not be able to raise it yourself!

If you run into this problem, you might need to upgrade your current hosting plan, switch to a better hosting provider that allows you to manually increase the memory limit yourself at a lower cost, or delete the plugin(s) that caused this issue and find a workaround.

Leave a Comment

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

Scroll to Top