Troubleshooting WordPress: How to Fix the White Screen of Death
2023-11-18 01:11:37 Author: blog.sucuri.net(查看原文) 阅读量:34 收藏

Navigating to your WordPress site only to be met with the White Screen of Death (WSoD) can be a daunting experience. This error denies access to your site for both administrators and visitors, disrupting your website’s performance and user experience. Despite its prevalence, this common WordPress problem has a number of straightforward solutions.

In this post, we’ll cover what the WordPress white screen error is, outline the most common reasons for this issue, and detail the steps you can take to resolve it. Our goal is to help you get your site back to normal as quickly as possible.

Let’s dive in!

Contents:

What is the WordPress White Screen of Death?

The WordPress White Screen of Death, sometimes condensed to WSoD, is an infamous error that transforms your carefully crafted WordPress site into a plain white screen. This error stems from issues within your website’s PHP files or database. Depending on the cause, it can either blanket your entire website in white or selectively affect certain areas like your WordPress admin dashboard or individual web pages.

The white screen error may present differently in various browsers. In Google Chrome, it can come with an HTTP 500 error warning, while in Mozilla Firefox, it can simply appear as a blank screen.

Example of a 500 error message
Example of a 500 error message.

Regardless of the browser you’re using, the error messages are not usually helpful in highlighting the actual problem.

What are the most common causes of a white screen in WordPress?

The White Screen of Death typically results from PHP code errors and conflicts, PHP version incompatibility, memory limit exhaustion, misconfigured .htaccess files, or database errors. These problems can be triggered by a number of things, including unresponsive scripts that are interrupted by your hosting server or exceed your PHP memory limit.

One common cause is faulty or incompatible themes or plugins on your website. If your front-end isn’t working but your WordPress admin area is accessible, it’s likely a theme or plugin issue. You can quickly verify your admin panel by navigating to yoursite.com/wp-admin.

Other potential culprits include parsing or syntax errors in your code, issues with caching, corruption in your files, or server downtime. Though its roots may vary and identification can be tough, the good news is there are actionable steps to mitigate and solve this error, which we’ll explore in the following section.

How to fix the White Screen of Death in WordPress

Let’s take a look at twelve steps you can take to troubleshoot and fix the White Screen of Death in WordPress.

  1. Retrace your steps
  2. Confirm the type of WSoD
  3. Review your WordPress error logs
  4. Temporarily disable your WordPress plugins
  5. Check your active WordPress theme
  6. Increase your WordPress memory limits
  7. Replace recently modified WordPress files
  8. Ensure PHP version compatibility
  9. Check your .htaccess file for issues
  10. Clear your WordPress and browser cache
  11. Run a scan for website malware
  12. Get in touch with your web host

Before making any changes, be sure to backup your WordPress files and database to easily revert back if you experience any issues.

1 – Retrace your steps.

It may seem like a no-brainer, but the first step requires you to take a quick moment to think about any modifications you have recently made to your WordPress site. For example, installing a new plugin or theme, altering core files, or updating to the latest WordPress version.

This will help identify if any recent changes in your environment are causing the issue. Perhaps a newly installed theme isn’t compatible with your WordPress version or a plugin update is causing a conflict with another plugin or theme.

  1. Review changes: Review all the recent changes, updates, or configurations that you have performed on your website. Did you change or update anything right before the white screen issue started?
  2. Revert back any recent updates: Undo the most recent changes one by one. This may involve deactivating a new plugin, switching back to a previous theme, or removing custom code snippets from your functions.php file.
  3. Test your site: After each reversal, check your website to see if the error has been resolved.

Checking for recent changes will help you figure out if an update or change you made triggered the white screen of death. Even better, you can pinpoint the exact tweak that’s messing with your site and work out how to fix it.

Remember: During the troubleshooting process website caching can be a major nuisance as it may prevent you from seeing recent changes you’ve made to the website. You may want to temporarily disable caching and place your website in maintenance mode while you are working on it. To circumvent some website caches and ensure that you are performing a proper refresh of the page consider adding a ?variable to the URL as you access the site like so:

hxxps://mybrokenwebsite[.]com?nocache

Didn’t help or no recent changes made? Let’s take a look at the type of white screen error you’re experiencing.

2 – Confirm the type of WSoD.

Before you go on a wild goose chase digging through error logs and whatnot, you’ll want to first confirm what HTTP response code your website is producing. This can save you a lot of time and you may discover that the fix is really quite simple.

First, load up your browser dev tools by pressing the F12 key on your keyboard, or by enabling it in your browser settings. This should display a new panel either at the bottom of your screen (Firefox) or the side (Chrome). Next, select the Network tab, which will allow you to see the response codes generated by the site. Now refresh the page and pay attention to the response code that is generated.

If the response code is 200, that means that the website is just loading a blank page. This typically indicates that there is either a blank index file present in your website, or that your theme files are missing. If this is the case, replace the index file (or remove the blank one if there is more than one) and double check that your theme files are present within wp-content/themes if not, you can re-upload a new copy.

On the other hand, if the response code is 500 then proceed with the next steps.

3 – Review your WordPress error logs.

WordPress has a built-in debugging system handy for troubleshooting. When activated, this system logs any errors that occur on your site, which may provide you valuable insight into what’s causing the white screen of death.

Here’s how you enable debugging and inspect the logs:

  1. Connect to your website using an FTP client and locate the wp-config.php file in your WordPress root directory.
  2. Open the wp-config.php file and add the following lines of code:
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);

This code enables WordPress debugging and instructs WordPress to log any errors.

  1. Save your changes and re-upload the file to your server.
  2. Browse your site until you encounter the white screen of death again. This will generate the debug.log file.
  3. Now, use your FTP client to look in the wp-content directory. You should see a new file named debug.log.
  4. Download and open the debug.log file. The error messages here will help you diagnose the white screen of death.

Enabling debugging and checking the error logs provide a direct insight into any problems happening behind the scenes without disrupting your site’s live version. Consider this your site’s “black box” that records any errors, making troubleshooting more effective.

Depending on your hosting environment, there may also be an error_log file present in the root directory of your website which should contain any recent PHP errors, warnings, or notices.

4 – Temporarily disable your WordPress plugins.

Plugins, while useful and (mostly) beneficial, can sometimes cause issues like the white screen of death. This next step involves disabling all your plugins to identify if any of them is behind the error.

Here’s how to temporarily disable your WordPress plugins to troubleshoot:

  1. Access your WordPress admin and navigate to the Plugins page.
  2. Select the checkmark at the top of table to select all installed plugins.
  3. Click on Bulk Actions and highlight Deactivate and then click Apply. 

Bulk deactivate plugins in WordPress dashboardThis step will deactivate all plugins and prevent them from running on your WordPress site.

If your site returns to normal, it indicates one of your plugins was causing the issue. To pinpoint the problematic plugin:

  1. Reactivate your plugins one after another, checking your site after each activation.
  2. If the white screen reappears, the most recently activated plugin is the culprit.

If you can’t reach your WordPress admin, don’t worry. You can still disable your plugins using an FTP client or your cPanel’s file manager:

  1. Log in to your favorite file manager and navigate to the /wp-content/ directory.
  2. Locate the plugins folder and rename it (e.g., plugins_deactivated). This step effectively turns off all your plugins.

If this step solves the problem, then it’s certain a plugin was at fault. You can reinstate the original name to your plugin folder, then rename each individual plugin’s folder inside it one by one until the issue shows up again. This way, you’ll discover the specific plugin causing the issue.

In some malware infections, bad actors are known to upload malicious plugins to the website to use as website backdoors or to inject malicious code into the environment. So if you’re experiencing a white screen error in WordPress, it’s definitely worth inspecting each plugin and removing any that don’t look familiar or have a suspicious name.

Plugins not the culprit? Move along to the next step.

5 – Check your active WordPress theme.

Much like plugins, a WordPress theme — especially a newly installed or updated one — can sometimes cause the white screen of death. In this step, your goal is to temporarily revert to a default WordPress theme and see if this resolves the issue.

Here’s how you do it:

  1. Log into your WordPress admin dashboard and go to the Appearance > Themes section.
  2. Deactivate your current theme by activating one of the default WordPress themes like Twenty Twenty-One, or Twenty Twenty-Three.

Default WordPress themes in the dashboard

Now, check if your site is back to normal. If it is, your theme was causing the issue. Maybe it’s not compatible with a plugin you’re using or maybe the error coincided with a recent theme update.

If you can’t access the WordPress admin due to the WSoD or if you’re having other issues getting the theme changed, then the theme can be manually changed in the database. Hop into your database either with PHPMyAdmin in your cPanel or by uploading the Adminer script to your website’s root directory. You can log in using the details present in your wp-config.php file.

Change the following three wp_options values in the database:

  • current_theme
  • stylesheet
  • template

They should have your current active theme listed there. Copy the current contents to a safe place and then replace them with a default theme name such as “twentytwentytwo” – just make sure whatever theme that you change it to is currently present in your ./wp-content/themes directory.

If you don’t have any other themes present you can download a fresh copy from the WordPress repository.

Once you are done with that, don’t forget to change the values back to what they were before and remove the adminer script for security reasons.

WordPress theme not the issue? Move along to the next step.

6 –  Increase your WordPress memory limits.

Sometimes, the white screen of death is due to your website exhausting its allocated memory. Scripts running on your website require memory to execute, and if these scripts require more memory than allocated, it could result in an error. This is why increasing the memory limit is a reasonable troubleshooting step.

Here’s how you increase the memory limit in WordPress:

  1. Connect to your site using an FTP client, and find the wp-config.php file in the main WordPress directory.
  2. Open your wp-config file and add the following line of code somewhere before the line that says, “That’s all, stop editing! Happy publishing.”
  define('WP_MEMORY_LIMIT', '256M');
  1. Save your changes and upload the file back to your server.

This new line of code in wp-config tells WordPress to increase the PHP memory limit to 256MB.

Now, revisit your website to check if the problem has been solved. No dice? Move along to the next troubleshooting step.

7 – Replace recently modified plugin, theme & core WordPress files.

Customizing HTML, CSS or PHP files of your WordPress site provides a high level of control. However, even a minor error or syntactical mistakes in the code can lead to a white screen of death. That’s why restoring recently edited files is an important troubleshooting step.

If you don’t have a recent website backup to conveniently restore from, here are the steps you can use to restore core, plugin, and theme files:

  1. Identify recently edited files: Determine the files you recently tweaked. These might include files from your plugin, theme, .htaccess or wp-config.php files.
  2. Get a fresh copy: If the file was part of core WordPress, theme, or plugin files then you can always get a fresh copy from the primary source. For example, if you’re using one of WordPress’ default themes, you can re-download it from the WordPress theme repository.
  3. Replace the edited file: Use an FTP client or the File Manager app in your hosting dashboard to replace the edited file with the fresh version.
  4. Check the website: Reload your website to see if the error persists.

Please remember to always backup your site before you start editing files, and (ideally) test changes on a staging version. That way, you can prevent “live” problems and easily restore things if something goes wrong.

It’s always better to err on the side of caution when it comes to direct modifications to your site’s source files.

8 – Ensure PHP version compatibility.

If all the previous troubleshooting steps have not been effective, sometimes a website can produce a 500 error WSoD due to the CMS, plugins or theme being incompatible with the PHP version in use on the server. This often happens to older websites which have not been updated for a while when their hosting provider updates the PHP version.

First thing’s first, search the exact PHP error that you are experiencing in your search engine of choice. Chances are other people have probably run into the same issue as you and attributed the culprit to the PHP version.

On the other hand, if you have recently upgraded PHP yourself try rolling that back to the previous version.

9 – Check your .htaccess file for issues.

A misconfigured .htaccess file can bring a website down very quickly. Some WordPress plugins will make changes to the .htaccess file (especially security plugins) so it’s good practice to temporarily rename your .htaccess file and replace it with a default copy. The default .htaccess for a WordPress environment looks like this:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

If everything else is configured properly and the .htaccess was the culprit then this should bring your website back up. If this is the case then you will want to review which rules in the .htaccess file were responsible for bringing down the website.

10 – Clear your WordPress and browser cache.

Clearing the WordPress cache is a crucial troubleshooting step as it eliminates any issues that could stem from stored data on your server or local machine.

Caching is a process that stores static versions of your content, which significantly speeds up loading times for your site’s visitors. However, if a problem arises like the white screen of death, this stored data might be part of the problem. Clearing the cache also helps ensure any changes you make while troubleshooting are not hampered by this old data.

Here are general directions for browsers, the Sucuri firewall, and caching plugins.

Clear browser cache:

Clearing your browser cache removes any stored data that’s been linked to the webpage.

For most browsers, you can access this option via the settings or history menu. It’s usually found labeled as ‘Clear Browsing Data‘ (Chrome)  or Clear Recent History (Firefox). Make sure you select ‘cached images and files’ before clearing, then reload your site in your browser.

Clear browsing data and cache in Google Chrome browser. 
Clear browsing data and cache in Google Chrome browser.

Clear cache with a WordPress caching plugin:

If you’re using a WordPress caching plugin (such as W3 Total Cache or WP Super Cache), navigate to the plugin’s settings in your WordPress dashboard. Look for an option labeled Clear Cache or Empty Cache. Click on it to clear your WordPress cache.

Clear cache with the Sucuri firewall:

Clearing your website’s cache with the Sucuri Firewall is simple.

To clear all page and file cache at once, simply go to Performance -> Clear Cache – Global in Sucuri Firewall’s settings. Then click the green Clear Cache button.

Clearing cache with the Sucuri firewall

After clearing your website and browser cache, check your WordPress site to see if the white screen error has been resolved.

11 – Run a scan for website malware.

In less common cases, malware can cause a white screen error in WordPress. Hackers can tamper with your website in numerous ways, from injecting harmful code into existing files to creating a wealth of malicious files. This illicit activity could provoke a 500 server error or a white screen of death.

Typical scenarios involving malware-induced errors include:

  • Injected harmful code containing bugs that cause site malfunctioning.
  • Malicious code is inserted in an incorrect location, breaking parts of your site’s legitimate code.
  • Legitimate website files or directories are deleted by malware.
  • Files are corrupted or encrypted by hackers, rendering them inaccessible.
  • The website’s storage space is exhausted due to an excessive number of malicious files.
  • Corruption of the database occurs as a result of the compromise.
  • The server’s resources are overly consumed due to processes initiated by the attacker’s tools, such as cryptominers or DDoS bots.

You can easily run a free website scan with the Sucuri SiteCheck remote website scanner. This tool will help you check your site for known malware, website errors, and other malicious code.

Sucuri SiteCheck Remote Website Checker

Remote scanners are not able to detect any malicious code found on the server level, however. To perform a comprehensive website scan, you can consider running a server-side scan to check for indicators of compromise and malware found on your site’s server as well.

That being said, identifying and removing the malware isn’t the final fix. If malware is the culprit, it’s equally important to determine how your site was infected in the first place and enhance protective measures. Regularly update your WordPress core, themes, and plugins, use strong passwords and login credentials, and set a frequent back up your site to avoid future attacks. You can also employ a web application firewall to help block bad bots, prevent hacks, and patch known software vulnerabilities.

12 – Get in touch with your web host.

If all other steps have failed to solve the issue, it’s time to reach out to your web hosting provider. These companies generally offer technical support and are well-equipped to help with issues like the white screen of death.

Here’s how to reach out to your host for help:

  1. Document the issue: Prepare a detailed explanation of the problem, noting any specific error messages you’ve encountered, the steps you’ve already taken to resolve the issue, and the outcomes of each step.
  2. Contact support: Get in touch with your hosting provider’s support team. This could be through live chat, a support ticket system, or phone call, depending upon what avenues your provider offers.
  3. Provide information: Give the support team the detailed explanation you prepared earlier. The more comprehensive information you can provide, the more effectively they can help you.
  4. Follow their instructions: Your hosting provider’s support team may ask you to perform certain actions or provide additional information. They may also be able to rectify the issue from their end or provide insights that help you understand the problem better.

Hosting providers are responsible for maintaining the server where your website is hosted. They can check for server-level issues, such as memory leaks, server downtime, or issues with the server’s database software, which could cause the white screen of death. Their expertise and access to server logs make them a valuable ally in resolving complex WordPress issues.

Overcoming white screen errors in WordPress

WordPress errors can sneak up on you for a host of reasons — often due to misbehaving plugins, theme files, or code incompatibilities. If you have a recent backup of your website on hand, you can quickly dodge this bullet by reverting your site to its last known good configuration.

It’s also worth running a thorough scan of your website for any signs of compromise or malware. In some cases, malicious code is known to trigger syntax errors, disrupt the smooth execution of your scripts, and break legitimate website code, resulting in unwanted white screen issues.

Get help removing malware from your website


文章来源: https://blog.sucuri.net/2023/11/troubleshooting-wordpress-how-to-fix-the-white-screen-of-death.html
如有侵权请联系:admin#unsafe.sh