500 Server Error - WordPress Login Page - WordPress Memory Issue Print

  • 12

There can be many reasons for a 500 Server Error, however, if your WordPress website is loading fine and when attempting to access the WordPress login page (/wp-admin) the reason could simply be an exhaustion of Memory. Even if you have the PHP memory set to a high limit (a minimum of 128 MB, but recommend 256 MB or more if possible) WordPress has its own limit of 40 MB. So this needs to be checked.

You will need to access your WordPress install files and look for the wp-config.php file. You can do so using cPanel File Manager or your favorite FTP Client.

STOP! BEFORE YOU CONTINUE, MAKE A BACKUP OF YOUR WORDPRESS SITE BOTH SITE FILES AND THE WORDPRESS INSTALLS MYSQL (MariaDB) DATABASE. You can never have too many backups. Now with that Warning given, let's move forward.

With FILE Manager (in cPanel) or your FTP program, look for your wp-config.php file in the WordPress web root directory.
NOTE: If you have your site installed in a subdirectory that subdirectory is going to be the web root directory.
On a cPanel server, the web root directory is going to be the /public_html directory. (On some installations for security reasons, you might find the wp-config.php directory outside of the  /public_html directory one level up in the /home directory. This directory cannot be reached via a web browser.
Note: /public_html is for most standard cPanel Servers. On Convesio Container Platforms it will be in the /wordpress/ directory.

Now, open the wp-config.php (if you are using Conesio Container Platforms, you will need to use the wp-convesio.php file instead) file in your editor or the File Manager File Editor and look for this:

/* That's all, stop editing! Happy blogging. */

Right above that (not below it!) add these three lines of code, simply copy and paste in

ini_set('error_reporting', E_ALL);
ini_set('error_log', dirname(__FILE__) . '/error_log.txt');

Then save the wp-config.php file.

Now go back to the login page that generated the 500 Server Error. This will trigger a /error_log.txt to be written with what is causing your error. In most cases the error will show something similar to this:

PHP Fatal error: The allowed memory size of 41943040 bytes exhausted (tried to allocate 3072 bytes) in /home/username/public_html/wp-admin/includes/update.php on line 502

If this is what you see, then it is the WordPress Memory limitation and that simply needs to be increased. And here is how to do this.

With the wp-config.php file still open (or open it back up) you will need to add the following code:

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

NOTE: You can change 256M to whatever you like, but I would not recommend anything lower than 128M. Before going above 128M you might check with Technical Support (at your web host) to make sure your PHP memory limit is the same.
right above this code in the wp-config.php file:

Now the above file must be placed right above this code:

/* That's all, stop editing! Happy blogging. */

Note: if you no longer need to track this type of error you can just remove the three lines of code that created the /error_log.txt file.


If you are a KartHost client and need help with this, feel free to open a Technical Support Ticket. We will be happy to help.

Thanks to Selena Forum Moderator at WPML.org for providing the code above to help us resolve an issue.

Learn More about Managed WordPress Hosting (so you do not have to do things like this) 
Get Your Name as a Domain Name! Register a Domain Name Today!

Was this answer helpful?

« Back