This article covers methods to resolve Nginx upstream timed out error. Basically, this error happens as a result of server resource usage and software timeouts.
A possible issue here could be that PHP is using too much RAM and the PHP FPM process gets killed.
Therefore, do the following to fix this nginx error:
1. Make sure that there is enough RAM on the server, to check that you could use the top, htop or free -m commands.
2. Make sure that the PHP memory limit is not too high compared to the actual available memory on the Droplet.
For example if you have 1GB of RAM available your PHP memory limit should not be more than 64MB otherwise only a few processes could consume all of your memory.
3. Optimize your website by installing a good caching plugin, that way you would reduce the overall resource usage on the server.
4. Delete any plugins that are not being used. Generally speaking, it is always recommended to try and keep the number of your plugins as low as possible.
5. Consider using a CDN like Cloudflare, that way it would offload some of the heavy liftings from your Droplet.