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

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
ShellScript

2. Deactivate all the plugins

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

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
ShellScript

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
ShellScript