I guess the repro is the general:
Get overwhelmed with requests, or have a patchy network.
504 would probably come from NGINX or a proxy along the way.
I agree entirely we can do better here (globally). We should never say “504 error” to users, we should always say “We are having a problem contacting the server” or something like that.
@martin can you add to your list seeing if there is some sort of global fix here? Not urgent, plenty of more urgent things we have.