It happens when I’m developing Drupal sites, writing custom modules and get a “502 Bad Gateway – nginx”. It can be hard to debug as 502 errors are usually caused when PHP freaks out for some reasons. There are many ways to detect where the errors are: logfiles that includes system stuff in /var/log/ and the nginx logs, or undo what you did, or disable all non-core modules to see if it works.
- Of course you have to install Drush first and you’ll need to access your server via SSH (here’s a good way to do SSH login without password using keys)
Print all non-core modules to a txt file
drush pm-list --type=module --status=enabled | sed '/\((.*)\)/!d;/[Cc]ore.*-.*[Rr]equired/d;s/.*(\(.*\)).*/\1/' | sort > noncoremod.txt
drush pm-disable $(cat noncoremod.txt)
This is when you found the problematic modules and you want to enable them back
drush pm-enable $(cat noncoremod.txt)