504 Gateway Timeout for some reports

What version of Discourse are you running? And also, how did you install it?

Also, can you try /safe-mode to see if the issue persists?