Website outage after slow response

Website responding extremely slowly and sometimes gives Error 502 – Bad Gateway. Whoops, something went wrong at our end! Please try again later or contact us if the problem persists.

Error 504 – Gateway Timeout. The server timed-out handling your request due to a temporary overload or long-running script. Please try again later or contact us if the problem persists.

Please check and help.