Another option might be to simply add a line to your php.ini file (or create one if you don’t already have one) and increase the PHP execution time. The php.ini file can go in your WP root, but it’s safer to keep it in your /wp-admin folder.
The line to add would be something like this:
max_execution_time = 30 (or make the value larger if that is what it’s already at or above)
You can read more about various fixes for a 502 error here: