504 Gateway Timeout error means that one server involved in displaying the web page did not communicate to another one quickly enough.
The HTTP 504 Gateway Timeout server error response status code indicates that the server, while acting as a gateway or proxy, did not get a response in time from the upstream server in order to complete the request.
9. Disable the CDN Web material is sent faster through a global network of servers known as content delivery networks (CDNs). CDNs are meant to make websites more efficient but sometimes they can cause delays leading to 504 Gateway Timeout errors. Turning off CDN temporarily helps in finding if this relates to CDN or not. This is how you ...

Such details provide a deeper understanding and appreciation for G Network Error 504.
Learn what a 504 error means and how to fix it fast. Get expert tips for site owners and users to prevent downtime and protect SEO.
You cannot prevent such errors. What you can do is find out what user experience there should be when such a problem happens, and implement it. BTW. If you get 504 errors, then you should also expect timeout errors. Say you make a request to your server with 60 second timeout, and your server makes a request to the proxy with 60 second timeout.

However, a faulty firewall configuration may mistakenly prevent legitimate network requests, leading to the 504 Gateway Timeout error. Follow these steps to turn off your firewall temporarily
Website errors can be extremely frustrating, and one that often appears is the 504 Gateway Timeout error. This error occurs when an upstream server fails to complete your request within a specified time frame.Network issues on the client side can also cause 504 errors.
A 504 Gateway Timeout error occurs when a server, acting as a gateway or proxy, fails to receive a timely response from an upstream server. Represented by HTTP status code 504, this error typically indicates network-related delays rather than issues on the users side.