Error 504 Gateway Time-out when trying to access a certain Internet resource is considered one of the most common. In this case, however, almost nothing depends on the user from whose computer the request is made to the page (it is possible that the browser version may need to be updated or even switched to another browser). But the owners of servers and sites located on certain hosting sites may encounter the problem of its appearance quite often. Next, let's try to briefly consider why such a failure occurs? and give some practical advice on how to possibly fix the recurring error.
Error 504 Gateway Time-out: translation and common understanding
To fully understand what, in fact, we are talking about, you first need to clearly understand the nature of this failure. If you invite readersthe simplest interpretation of the 504 Gateway Time-out error, the translation could roughly mean something like a timeout for passing through the gateway. But this applies only to those cases when accessing the requested page exceeds the resource's response timeout. That is, a request from a remote computer to a resource passes without problems, but the server does not have time to process the request and send a reverse htttp response in the allotted time.
This can be explained with a simple example, when the Apache server is installed as the backend, and nginx plays the role of the frontend. 504 Gateway Time-out is the most common response in this pair. The circuit works in the following way.

The client request to the server is not sent directly to Apache, but first goes through nginx (something like a distributor). If the Apache server is unable to process the request and send a response within the allotted time, nginx generates this error if there is no response. In general, it is worth saying that almost all versions of the Apache server have one rather unpleasant feature, which is that they do not really have a sufficiently high request processing speed. In addition, their work can also be affected by a huge number of currently active third-party processes and executable scripts, the work of which can also fail.
Error 504 Gateway Time-out: hardware troubleshooting on servers
Now let's move from theory to practice and try,as far as possible, try to fix this annoying glitch.

Usually, experts recommend server owners in the simplest situation to use the simplest method for eliminating the 504 Gateway Time-out error, which involves increasing the power of the equipment in order to increase the performance of computers. You can try to increase the amount of RAM on the server, install newer processors, etc.
Fixing an error with the simplest software method on websites
As for the pages themselves and the hosts they can host, when using the Apache + nginx bundle, as a first resort, you can try to increase the number of httpd processes directly on the Apache server. In addition, a more reasonable solution can be applied. As mentioned above, the server does not have enough time to process the request, and the distributor sends a 504 Gateway Time-out error instead of a response. The PHP parameter max_execution_time needs to be changed to a larger value for the time period (for example, in the region of 500-700 seconds).

In addition, it is highly recommended to check all active third-party processes and disable those that are simply not needed. Particular attention should be paid to SQL queries and executable scripts.
Problems with script execution
But with scripts, things are not so simple.

Mistakes caused by them usually happen for a reasonthe fact that the scripts themselves can access data on the site or external databases that are not available at a certain point in time, and, again, do not have time to get an answer. It is not uncommon for a 504 Gateway Time-out error to be caused by an attempt to connect to a proxy server that cannot process the incoming request and send a response. Finally, do not forget that quite often access to data can be blocked by third-party processes (for example, weather applets or widgets of current exchange rates, etc.). Accordingly, it is necessary to optimize their performance as well.
Error when using Joomla management system
Finally, the 504 Gateway Time-out error in 504 in Joomla most often appears corny due to the fact that the control system itself is constantly updated, which does not affect its functioning in the best way. So, for example, many experts note that the "boxed" modification of Joomla 3 must be optimized by installing additional modules and plugins. But updating the system itself to version 3.6.5 can provoke conflicts with the codes of installed obsolete add-ons, which leads to a slowdown in the server and the appearance of the described failure. Accordingly, all add-ons also need to be updated (although keeping track of the automatic constant updating of the Joomla system itself can be very problematic).
Alternatively, you can make a copy of the entire site for yourself by creating a new directory at the root and placing copies of all files there. Then create a copy of the database and write its configuration(Configuration.php).

Now go to the Joomla admin section, then in the plugins section disable add-ons one by one, starting with the ones that were installed last. It is possible that one of these plugins is causing this problem. For example, some note that very often the error pops up due to the fault of the JSitemap Pingomatic add-on.
Additional advice for site owners
If you are just the owner of the site and host it on a certain hosting, but none of the above can solve the problem, it is quite possible that it is time to think carefully about changing the hosting provider, which is not able to provide you with a normal technical support.