The responding server, acting as a gateway/proxy, timed out waiting on a further server it depends on (Server Time-out).
Where you see it
In the status line of a SIP response, often with Reason and Warning headers that say more.
What to check
Check the further server this one depends on for the actual delay/failure.
Read the Warning and Reason headers of the response and the Via/Server of the node that sent it.
Got a trace with SIP 504 Server Time-out? Drop it in the analyzer: it finds the step that really failed first, which node sent the code and what to ask the other side. Captures, test-system PDFs and vendor exports. 5 free analyses a month, no sign-up.