Ilias Kypraios
Ilias Kypraios

Ilias Kypraios

Use WP-CLI to Identify a Plugin That Causes a 500 Error

Use WP-CLI to Identify a Plugin That Causes a 500 Error

Ilias Kypraios's photo
Ilias Kypraios
·May 15, 2022·

1 min read

Subscribe to my newsletter and never miss my upcoming articles

Do not attempt this on a production website, create a staging and try debugging there

1. Create a list with all the active plugins

wp plugin list --status=active --field=name > plugins.txt

2. Deactivate the plugins one by one and curl the HTTP response

awk '{print $1}' plugins.txt | while read a; do wp plugin deactivate $a --skip-plugins && curl -sILX GET https://staging.kipreos.me/ | head -n 1 && wp plugin activate $a --skip-plugins; done

The script will deactivate the plugins one by one and check the HTTP response. Once the plugin that creates the problem is deactivated you will see the curl check returning an HTTP/1.1 200 OKresponse.

3. Enable again all the necessary plugins to restore the site to the previous condition

awk '{print $1}' plugins.txt | while read a; do wp plugin activate $a --skip-plugins; done
 
Share this