So what happens here is that the server is rebooted for that process. Anything that might change on reboot would then change. What can often be the case is that software has been installed and is running, but hasn’t been set to automatically start at boot time. That means on reboot the software isn’t running, and then you an error.
A 502 error means that the web server failed to reach a back-end service that is required to display the website. This is somewhat consistent with my above theory. Are you running PHP-FPM by chance? If so, you might try starting it up manually. That varies by distro and version, could be something like one of these:
service php-fpm start
systemctl php-fpm start
systemctl php7-fpm start
You might look for the actual name in /etc/init.d (for “service” command) or /etc/systemd/system (for systemctl command).
If not PHP-FPM, could be something else. Do you know what the details of your software stack are?