Hello Matrin,
I am sorry about the issue you are experiencing and I am happy to assist you with this.
The HyperText Transfer Protocol (HTTP) 502 Bad Gateway server error response code indicates that the server while acting as a gateway or proxy, received an invalid response from the upstream server.
YOu’ve mentioned that the server capacity is reached, so you may want to check the /cache/ folder and delete the content (don’t worry, the files will be cached again) if W3 Total Cache is active
Make sure that if you are caching to disk to disable Object Caching and Databased Caching as it’s not recommended to use those options if caching to disk.
Every 500 error should be logged so I would advise enabling wp_debug and checking the error log once, and if the error occurs again.