How to fix 500 internal server error due to memory limit

How to fix 500 internal server error due to memory limit?

1. First of all you will need to find the reason why you are getting 500 internal server error. To find out, open your Cpanel > File manager and open config.php file


2. Next, turn WP_DEBUG and WP_DEBUG_DISPLAY to true. If you do not have these lines of code then add it manually. This will show the actual error message in your site

3. If you have error like:

Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 3072 bytes) in /home/offerayo/public_html/ on line 36

then it can be fixed by increasing wordpress memory limit. Put following line in your wp-config.php file
define(‘WP_MEMORY_LIMIT’, ‘256M’);

4. The final code should look like this:

5. Now check your site. It should work fine. After you are ensured that your site is running fine, then make WP_DEBUG and WP_DEBUG_DISPLAY to false otherwise your visitor might see error message whenever they are encountered.

6. That’s all…

Thanks Dilip Thakuri for the help.