How to increase PHP Memory Limit in cPanel

In this article, we will explain the PHP Memory limit error in cPanel, and show a quick and easy solution for it. It requires a simple access to the cPanel shared hosting account.

Why does the Memory limit error happens ?

Sometimes when you execute a PHP script, you will notice that it returns an error like “Fatal Error: Allowed memory size of XX bytes exhausted”. This happens because the amount of memory allocated to the PHP script has exhausted, and as a consequence, the script cannot finish its execution. It’s already known as PHP Memory Limit Error.

The amount of memory available to PHP is defined by the term memory_limit in your server’s PHP settings. With the help of cPanel, you can change this value to anything you like. How that can be done is described below.

How to fix this issue

First, log in to your cPanel account using your cPanel username and Password. If you forgot the password, you can reset it using the ‘Reset Password’ option on the same page.




Once you are in the dashboard, go to Software -> Select PHP Version.



Click on it and it will take you to an interface where you can change the PHP version and select/deselect extensions. To the top right side of the page, you will see another option ‘Switch to PHP Options’.



Click on it and you will reach an interface which displays the various PHP variables and its associated values. They become grey by default. To change the PHP memory limit, click on the value to the right side of memory_limit. Then, a drop-down will appear with possible values you can choose. Select the value you require and hit ‘Apply’. After that scroll down to the bottom and click on ‘Save’. Only then the changes will be fully applied.


php memory limit

You can confirm whether your changes have got into effect by creating a PHP file with the following contents in it. Suppose I create a file named info.php. Enter the following into it.


Save the file and upload it into your domain’s public_html folder. Our domain name is and we can view the file as You can now see your PHP settings in the browser by simply accessing in a browser. Search for the option ‘memory_limit’ to confirm whether the new value you modified has taken effect. In my case, it is correctly showing it as 256M as displayed in the image below.

memory limit

This is a very useful and easy way to get rid of the “Allowed memory size of XX bytes exhausted” message because you can change these configuration values in cPanel anytime.




Leave a Reply

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