Ilias Kypraios
Ilias Kypraios

Ilias Kypraios

Use WP-CLI to Identify a Plugin That Causes a 504 Time Out Error

Use WP-CLI to Identify a Plugin That Causes a 504 Time Out 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 all the plugins

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

3. Enable the plugins one by one and curl the HTTP response

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

The script will activate the plugins one by one and check the HTTP response. Once the plugin that creates the problem is activated you will see the curl check returning an HTTP/1.1 504 Gateway Time-out response.

4. 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