Close. See quotes below from the internet. One is an invalid response. One is no response
The 502 Bad Gateway HTTP status code means that one server received an invalid response from another server that it was accessing while attempting to load the web page or fill another request by the browser.
In other words, the 502 error is an issue between two different servers on the Internet that aren't communicating properly.
The 504 Gateway Timeout HTTP status code means that one server did not receive a timely response from another server that it was accessing while attempting to load the web page or fill another request by the browser.
This usually means that the other server is down or not working properly.