If you use a proxy server for your internet activity, and you are unable to fix a 504 error by refreshing the page or restarting the browser, you should check your browsers settings. The configuration could be defective and you should try to select a different proxy to work on.
Another solution to this problem would be restart all of your network devices. Temporary problems with your modem, router, switches, or other networking hardware could be causing the 504 Gateway Timeout issue you're seeing. Just restarting these devices could help.
It might be possible 1) to also make use of a proxy server, configuring it appropriately in your operating system or in your browser. There are also some free public proxy servers, which are rather slow. Another potential solution is 2) to use one of the so-called DNS redirectors. Be also aware of possible resulting breaches of the respective law :)