General    April 13th 2017    0 Comments

4 Ways To Fix White Screen of Death In WordPress

During my nearly ten year career as a WordPress developer, I have met with the WordPress white screen of death many times. Do not worry, the content of your site is not gone, it is still in the database and can be resurrected. In the following introduction, I’ll present why this phenomenon is happening in WordPress. Then I will show several solutions that helps resolve the problem in 95% of the cases.

Why is the WordPress White Screen of Death happening?

No one writes perfect code, especially part-time WordPress developers. I do not know any other theme developer, who tests his codes in 10+ different development environments, like we do at FRESHFACE, before pushing anything out to the world. So it’s just a matter of time before some odd PHP error pops up, which will take down the whole server. On localhost server, the error printing is usually turned on, so you can see the error message. But on production servers, the error printing is usually turned off by default (due to security reasons). So what happens is that the error is suppressed in the background, therefore not printed and all you can see is a blank white page.

1. Display the hidden error message

The most annoying part. You need to turn on the WP_DEBUG constant and simultaneously turn on the printing of PHP errors. Because turning on the WP_DEBUG only is not enough in most cases. Both can be done by editing your “wp-config.php” file. Find the line:

define('WP_DEBUG', false);

And replace it with:

define('WP_DEBUG', true);define('WP_DEBUG_DISPLAY', true);error_reporting(E_ALL);ini_set('display_errors', 1);

Although there are more than 40,000 WordPress plugins, there aren’t any good plugins to simply activate the WP_DEBUG mode. In rare cases, the WordPress Debug mode can be turned on inside your theme options. For example we have this functionality already implemented in our Ark WordPress theme. If you are a developer, you can take this as a tip for future improvements of your themes/plugins.

Now refresh your page and you should see the error message. If you still see the white screen, then you have a poorly configured server and you need to contact your hosting provider.

2. Increase PHP memory limit

If the error from the first step of this guide includesAllowed memory size of XXX bytes exhausted (tried to allocate YYY bytes) in PHP”, then it is a problem of having a low PHP memory limit. An indication of the amount of memory is usually in bytes (converting bytes to megabytes can be done via Google). You basically have two options here.

There are several ways to do this, and not all of them will always work. I recommend trying one after the other.

First method

The first is the classic usage of “ini_set” function. The code will look something like this:

ini_set(‘memory_limit’, ‘128M’);

Note that M stands for megabytes. You might be concerned about how big value to set. Our Ark WordPress theme works perfectly with 128M. But other similar themes such as Avada, X, Enfold or BeTheme usually require 256M or more. So start with 128 and work your way up if needed.

Second method

If you have increased the memory limit using the first method, but you still get the samebytes exhausted” error message, then your change has not been reflected. The next method you can try is to edit your “php.ini” file (google the right folder). Find the line:

memory_limit = xxM

And replace it with:

memory_limit = 128M

If 128 is not enough then try increasing it even more, as explained in the first method. Please remember to reset your Apache server after this change. If this method still does not increase your PHP memory limit, then you have no choice but to contact your hosting provider and ask them for assistance.

3. Deactivate problematic plugin

Error message usually shows the file in which the error occurred. Excluding the “Allowed memory size of XXX bytes exhausted (tried to allocate YYY bytes) in php” error, any other errors are most probably serious problems in the code. Luckily for us, the error shows a path to the problematic file. If the path contains string such aswp-content/plugins/[plugin-name]”, then its a problem with that plugin and needs to be disabled. If you can access your wp-admin, then simply de-activate the plugin. If you cannot access it, then delete or rename (much faster) the plugin folder via FTP. This will automatically deactivate the plugin because WordPress core will not be able to find it and should not cause any issues.

4. Deactivate problematic theme

Honestly, these things should not happen. At all. If they are really happening, I suggest you to buy a different theme, because your current one is definitely not well written. You can find out if the theme is indeed a problem by finding a “wp-content/themes/[your-theme-name]” string in the error. If that is the case, then you have two options. If you can access WP Admin, simply de-activate the theme. If you cannot access WP Admin, just delete or rename (much faster) the theme folder via FTP. This way the theme will be automatically de-activated and the default WordPress theme will activate in it’s place.

Conclusion

First, it’s important to print the PHP error that is usually hidden by default. This is the only way how you can realistically figure out what actions to take to resolve the problem. If it’s a memory limit issue and you can raise the memory limit, then raise it. Otherwise see if the error is in plugin or theme and then de-activate it. If you cannot de-activate it, then delete it via FTP.

x

We use cookies to give you the best online experience. By agreeing you accept the use of cookies in accordance with our privacy policy. Learn More