Error 500 after a plugin update: safely deactivating the plugin

WordPress 5 min read

If, after updating a plugin, your website returns a 500 error or displays the message ‘A serious error has occurred on our website’, it is almost always because the new plugin code is incompatible with something: the PHP version, another plugin or the WordPress version. The update overwrites the existing files; the plugin remains active, and WordPress attempts to load it with every request, which is why the admin dashboard may also stop working.

The order of steps is as follows: first, restore the website, then find out what the problem was. Our blog post discusses other causes of the 500 error (.htaccess, permissions, PHP settings). We tested these steps using a deliberately corrupted plugin on a test website hosted on a cPanel hosting account.

1. Check the error log

On aWh’s cPanel servers, PHP writes error messages to the logs/php.error.log file in the home directory, and an error_log file may also be created in the website’s root directory. The line containing the fatal error specifies the file name and, consequently, the plugin:

PHP Fatal error:  Uncaught Error: Call to undefined function kb_nem_letezo_fuggveny() in /home/felhasznalonev/public_html/wp-content/plugins/pelda-bovitmeny/pelda-bovitmeny.php:6

In Terminal or via SSH:

grep -i "fatal" ~/logs/php.error.log | tail -n 5
ls -lt ~/public_html/wp-content/plugins/ | head -5

The second command lists the most recently modified plugin directories: the plugin that was just updated is the prime suspect. Without SSH, you can open the log via the cPanel File Manager (the logs directory is located in the home directory).

In the event of a ‘critical error’, WordPress also sends an email to the admin’s address, containing a recovery link that allows them to log in to the admin panel without the faulty plugin. This is discussed in the article on the white screen.

2. Disable the extension

WP-CLI runs WordPress’s own shutdown process, just as the admin interface does. If the error occurs whilst the plugin is loading, WP-CLI itself will also hang (the wp plugin list command will display the same fatal error). In this case, use the --skip-plugins switch to skip the faulty plugin during loading:

cd ~/public_html
wp plugin deactivate pelda-bovitmeny --skip-plugins=pelda-bovitmeny

The answer: Plugin 'pelda-bovitmeny' deactivated. You can identify the name of the plugin (the name of its folder) from the error message path. For multi-site installations or plugins enabled at network level, add the --network’ switch.

WP-CLI is available in plans that include SSH access (cP Premium, cP Pro, cP Pro 100); the basics are described in the article on using WP-CLI.

Renaming a folder (without SSH)

In the cPanel File Manager, open the public_html/wp-content/plugins folder and rename the plugin folder, for example to pelda-bovitmeny.hibas. WordPress cannot find the code, so it does not load it, and the website became accessible again immediately during the test.

This is the quicker, but rougher, method: according to WordPress, the plugin remains active (the missing file remains listed in the active_plugins setting), and its own deactivation steps do not run, so its scheduled tasks and settings remain in place. Once the website is up and running, open the Plugins page in the admin panel: WordPress will then indicate that the plugin is missing and deactivate it.

If errors persist even after the service has been switched off

Check whether the plugin still has any scheduled tasks, as these may continue to cause the error in the background:

wp cron event list | grep -i pelda

3. Revert to the working version

  • WP Toolkit restore point: if the update was carried out by WP Toolkit and the restore point was enabled, you can revert to a previous version with a single click on the website’s card.
  • Daily backup: on the JetBackup interface, you can restore just the plugin folder from the day before the update (backup).
  • Previous versions from WordPress.org: on the plugin’s WordPress.org page, click the ‘Advanced View’ link to download older versions at the bottom of the page. In one step with WP-CLI:
wp plugin install pelda-bovitmeny --version=1.4.2 --force --skip-plugins=pelda-bovitmeny
wp plugin activate pelda-bovitmeny

4. Read the error message before switching it back on

The most common scenarios:

  • Call to undefined function str_contains() or another, newer PHP function: the plugin requires a newer version of PHP than the one currently used by the website. Switch to a newer PHP version via the ‘Select PHP Version’ interface (PHP version settings), or continue using the old plugin version. After changing the PHP version, check the entire website, not just this plugin.
  • Class "…" not found: this refers to a WordPress class. Your WordPress version is too old for this plugin. Please update WordPress.
  • Cannot redeclare function …(): two plugins are using the same function name. Please remove one of them or report this to the developer.
  • Allowed memory size of … bytes exhausted: the new version requires more memory. This article discusses this memory limit.

If there is nothing in the log, enable WordPress error logging (debug mode) and try to reproduce the error.

5. Next time, with less risk

  • Make a note of the extension and version (for example, ‘the example-extension 1.5.0 requires PHP 8.1’) so you don’t have to look it up again next time.
  • Please update important plugins on a staging copy first.
  • Enable the restore point or the Smart Update feature in WP Toolkit, which first tests the update on a copy of your site. A separate article compares the different update methods.

If your website has started returning a 500 error on its own, without any plugin updates, the article on general 500 errors and the article on CloudLinux resource limits should help. If you get stuck, please contact our support team.

Back: WordPress articles (43)