In this circumstance, a 504 error indicates the server has timed out prior to receiving a response, this could be due to low bandwidth or high file volumes.
We recommend downloading your firm's documents in sections versus all at once, specifically isolating the category or categories with the most documents and downloading them separately.