504 is the HTTP status code for "gateway timeout". This error message is typically returned when there has been an unexpected temporary failure in returning a response to the requesting client.
It can also be used if the server is waiting for something from the client before it can continue processing requests. A typical example of this would be where a user has closed their browser window before completing downloading content that they were viewing within another browser window.
This often means either the webserver itself is failing to reply, or more likely, some component it uses (or backend it points to) did not reply in time.