Common mistakes in shared hosting and how to deal with them. The maximum number of processes is running. What does the “504 Gateway time out” error mean?

The 504 Gateway Timeout error is an HTTP status code that means one server did not receive a timely response from another server it contacted while trying to load a web page or fulfill a browser request. It may occur in conjunction with 502 Bad Gateway.

In other words, error 504 indicates that the server on which the site is located and the computer on which the 504 error appears do not have a sufficiently stable fast connection with the Internet.

How can you see a 504 error?

Individual sites are allowed to customize the display of the Gateway Timeout error. Here are some common ways to display this error:

504 Gateway Timeout HTTP 504 504 ERROR Gateway Timeout (504) HTTP Error 504 - Gateway Timeout Gateway Timeout Error

The 504 Gateway Timeout error appears inside a browser window just like a regular web page. It may have familiar top and footers site and a beautiful English message. An error like this may also appear on a completely white page with a large 504 at the top. It's the same message no matter how the site displays it to you.

Remember that 504 Gateway Timeout and 502 Bad Gateway ngin errors can appear in any browser, operating system and on any device.

Reasons for the 504 Gateway Timeout error

In most cases, the 504 Gateway Timeout error means that any server that is timing out has crashed or is not working properly.

Since this error usually occurs between servers on the Internet, it is likely not related to your computer, device, or Internet connection.

How to fix 504 Gateway Timeout error

  1. Reload the webpage by pressing the refresh/reload button in F5 or repeating the URL from the address bar.

Although the 504 Gateway Timeout and 502 Bad Gateway error report an error that is beyond your control, the problem may be temporary. Just reload the page - it's quick and easy.

  1. Restart everything network devices. Temporary problems with your modem, router, switches, or other network equipment may cause a 504 Gateway Timeout error. Simply restarting these devices may help.

Hint: While the order in which these devices are turned off is not important, the order in which they are turned on is very important.

  1. Check the proxy settings in your browser or application. Make sure they are correct. Incorrect settings Proxy servers can cause a 504 error.

Clue . See Proxy.org for an updated, verified list of proxy servers that you can use.

Note: Most computers do not have proxy settings, so if your settings are empty, skip this step.

  1. Change the DNS server. It's possible that the 504 Gateway Timeout error you're seeing is caused by an issue with the DNS server you're using.

Note: The DNS server you are currently using is probably automatically assigned by your ISP. Luckily, there are other DNS servers available for use that you can choose from.

Clue . If not all network devices receive HTTP error 504 or 502 error Bad Gateway, but they are all on the same network, changing the DNS server will not work. If this sounds like your situation, move on to the next idea.

  1. If there are no changes, please check the website. This is the only thing you can do. There's a good chance that site administrators are already working to fix the root cause of the 504 Gateway Timeout error.

Most sites have Accounts social networks, which they use for support. And some even have phone numbers and email addresses.

Clue . If a site starts to seem like it's throwing a 504 error to everyone, look on Twitter for real-time information about the site being unavailable. The best way to do this is to search #websitedown on Twitter. For example, if Facebook might be down, search for #facebookdown.

  1. Contact your internet service provider. Most likely, after troubleshooting the above, the 504 Gateway Timeout that pops up is a problem caused by a network problem that is the responsibility of your ISP.
  1. Come back later. On this moment you have exhausted all options and the 504 Gateway Timeout error is resolved by the site administrator or ISP.

Check the site regularly. No doubt it will start working again.

Fixing 504 Error on Your Own Website

In most cases, this happens not through your fault, but also not through the fault of the users of your resource. Start by verifying that the server can properly provide access to all the domains that your applications require access to.

Large volumes of traffic may cause your server to issue a 504 error. Although a 503 or 502 Bad Gateway error will be more likely.

In WordPress specifically, the 504: Gateway Timeout message sometimes occurs due to corrupted databases. Install WP-DBManager and try using the "Restore DB" function and then " Optimize the database" See if this helps.

Make sure your HTACCESS file is correct. Especially if you just reinstalled WordPress.

Connect with technical support hosting. It's possible that the 504 error your site is returning is due to an issue on their end that they need to resolve.

More ways to see a 504 error

Gateway Timeout error when receiving in Windows Update generates error code 0x80244023 or message WU_E_PT_HTTP_STATUS_GATEWAY_TIMEOUT.

In programs on Windows based that initially access the internet, a 504 error may appear in a small dialog or error box with an HTTP_STATUS_GATEWAY_TIMEOUT error and/or message The request was timed out waiting for a gateway (Gateway request timed out).

A less common 504 error is Gateway Time-out: The proxy server did not receive a timely response from the upstream server (the proxy server did not receive a timely response from the upstream server), but troubleshooting (mentioned above) continues.

Error 504 Gateway Timeout - causes and solutions - 4.6 out of 5 based on 15 votes

Error 504 - what it means, why it occurs and how to get rid of it, these points are discussed in detail in this article. I hope that after reading them you will be able to take certain actions and get rid of this error occurring on your site.

What does error 504 mean?

Error 504 Gateway Timeout means the gateway timeout has expired. User can see this code errors in the event that the server, working as a proxy server or gateway, contacted a server higher in the hierarchy with a request, but did not receive a response in time.

Servers that have Apache installed as the backend and nginx as the frontend most often generate this error code. The user’s work with the server occurs according to the following plan: the client sends a request to the server, which does not go directly to Apache, but is sent through nginx (this is something like a request distributor). If the latter was unable to receive a response from Apache within a set period of time, it sends the client a server error message 504 (Gateway Timeout) instead of the required result.

Reasons for the error

Lack of resources on the server due to heavy load.

The Apache server has one not very pleasant feature - under heavy load and lack of resources, it does not have time to process a large number of requests and provide http responses to them in a timely manner. This way, client requests are queued up and when the time limit for receiving a response runs out, they are discarded with nothing. As a result, the user sees an error code 504 (Gateway Timeout) on the browser page.

It should be noted that it is not always high load due to a large number visitors, but this is not uncommon. You can look at the article "", where the causes of the load are discussed in more detail.

Errors made in scripts.

Another reason for this error to appear is errors in executable scripts. As a rule, a certain amount of time is allotted for the execution of the script, but in some cases this time is not enough. This often happens when a script accesses a third-party server and does not always manage to send a request and receive a response within the allotted time limit and, as a result, produces an error.

The following reasons for the delay in script execution can be identified:

1. The script tries to access an external database, which, for various reasons, is currently impossible to access.

2. The script tries to obtain data from the server that is not currently available (an example could be the work of various weather widgets, exchange rates, etc.)

3. The script tries to establish a connection through a proxy server, which is currently unavailable and cannot process the request.

Ways to resolve the 504 error

Let's look at a few common cases and try to understand how to fix the 504 error.

If the error occurs due to server load, then first of all you need to take the following steps:

1. Optimize the server.

2. Optimize scripts.

3. Increase the resources available to the server (number of httpd processes (Apache), RAM, etc.)

4. If the resource is located on virtual hosting, you should consider changing your tariff plan or purchasing a virtual dedicated server. On simple shared hosting, only the administrators of the hosting provider can improve the situation. Because this may be due to their actions or the actions of the hosting provider’s management as a result of too many accounts being placed on one server. In case of their inaction the best option will completely change the hosting provider.

If you need high-quality virtual hosting, you can pay attention to a hosting provider that provides this service in good quality.

If you suspect the scripts are working:

It is necessary to check the functionality of the resources that the scripts access. Very often the problem lies precisely in them.

It is worth checking over what period of time the scripts are executed and whether they fit within the allotted limit. If necessary, then configuration file php.ini needs to increase the php_max_execution_time value. This parameter determines the execution time of the script, usually 30 seconds, if necessary you can set it to 60.

Inappropriate PHP version activated

Perhaps your site requires a certain PHP module to function, which is not included in current version. Try switching the PHP version to another: .

It may happen that one site requires one version of PHP, and another site requires another. Since the PHP version changes for the entire account, you can solve the problem by dividing the sites into two hosting services.

Site files are located in the wrong directory

Site files should be located in . If this is not the case, place the site in the correct directory.

Incorrect permissions are set on site files and directories

In most cases, the correct permissions for directories are "755", and for files "644".

Errors in the .htaccess file

Invalid rules in the .htaccess file are also a common cause of the error. If you made changes to .htaccess yourself, try removing them and checking the accessibility of the site.

It may also help to replace the current .htaccess file with the default one for your CMS:

Maximum number of processes running

On shared hosting, the site has a limit of 18 simultaneously running processes (). If this limit will be achieved new process will not be able to start and an error will occur.

The limit (18 simultaneous processes) can consist of CRON jobs, frequent connections using email clients IMAP protocol, FTP connections or other frozen processes.

You can check the current number of running processes by running the command:

ps aux | grep [u]1234567 |wc -l

To see which processes are running, enter the command:

ps aux | grep[u]1234567

The command line will display running processes, each process has the form:

The process can be terminated with the kill command, for example:

Where 40522 is the PID of the process.

It may also help you:

  • increase the CRON job launch interval;
  • limit the number of IMAP connections in settings mail client: ;
  • analyze running processes yourself or by asking the site developers for help.

The limit on the number of PHP processes has been exceeded

The error can also occur due to exceeding the limit on the number of PHP processes, according to tariff plans Hos t maximum amount processes PHP is 4, on tariff plans VIP - 32. You can view running processes using the command ps aux,

ps aux | grep php | grep u1234567

where u1234567 is your hosting login.

You can terminate current PHP processes by changing the PHP version to something other than the current one and then enabling the PHP version that was previously installed.

Common causes of errors on VPS

On VPS server, in addition to errors in the .htaccess file and the incorrectly selected PHP version, the reason may be the lack of free disk space or objects file system. You can find out the meaning of these two parameters in, on the service management page:

If any parameter has reached the limit, use the help:

  • if the error is not displayed immediately, but after certain actions(adding an image, submitting a form from a website, importing files...), describe detailed order actions by which we can reproduce the problem;
  • If you need to log in to the administrative part of the site to reproduce the problem, provide the appropriate access credentials (login and password).
  • Surely many Internet users and computer networks More than once we have encountered such an unpleasant situation as the appearance of a 504 (error) code in the browser. Not everyone clearly understands why such a failure occurs and how to fix it all. Let's see what's what.

    What does the “504 Gateway time out” error mean?

    First of all, in the very in simple terms error code 504 can be interpreted as a timeout for a response to a request sent from the user computer terminal to a remote server located on the Internet.

    In other words, processing this kind requests simply have their own time limits during which the server must send feedback. On different servers this time has different meanings. In any case, if a message with code 504 (error) appears, it means it has simply expired, that is, no response was received from the server during this time period.

    Reasons for the error

    Now, as simply as possible, let’s touch on the technical aspect. So, we get error 504. What does this message mean from the point of view of interaction between the user terminal and the remote server?

    The following explanation may seem a little difficult to understand, however, everything is simple here. The fact is that such failures mainly manifest themselves during interaction Apache platforms and nginx, when the first is installed as the final server, and the second as a means of processing incoming requests. It turns out that the user request is not addressed directly to Apache, but undergoes preliminary approval with nginx, after which it is sent to the server installed as the backend.

    It is clear that if nginx does not receive a response from the Apache server on time, it instead of the expected result gives the user a message with code 504 (error). However, such situations can be corrected, even in the most basic way.

    Code 504 (error): how to deal with it?

    Despite the apparent seriousness of the 504 error, there is actually nothing wrong with it. As the most simple remedy resuming access to the required resource can be called a normal page refresh in the Internet browser used.

    Typically this is either the "Update" button or using function key F5. This rule applies to all browsers without exception. However, a longer option is possible when the connection is unstable. It may very well be that in in this case you will have to reboot the entire system or even the router (particularly when using Internet access via a Wi-Fi connection).

    Among other things, problems may also be associated with excessive load on the server or scripts running on it. There's nothing you can do about it - you'll have to wait until the load subsides. By the way, in most cases such situations very often occur when a so-called DDoS attack is carried out on the server, as a result of which the server simply does not have time to process great amount simultaneously arriving requests.

    Sometimes the problem may be that the server is currently operating in proxy or gateway mode, through which sending requests is either limited or impossible. The proxy settings have probably gone wrong - they need to be checked or reinstalled.

    Problems installing applications

    However, this is not all. Quite often an installation error (code 504) may appear when an application or program is installed directly from the Internet. In this case, the distribution is not downloaded to the hard drive, but is located on remote server, from which the installation is carried out.

    It is clear that if there are restrictions on connection speed or depending on the performance of the resource itself, such a process can take a lot of time, or even stop altogether. Sadly, the installation will not have to be resumed from some point, but rather restarted.

    By the way, if incorrect operation is observed executable scripts responsible for this process on hosting, it is recommended to use editing the php.ini file, in which you need to find the line php_max_execution_time and change the standard execution time value from 30 seconds to higher value. But you shouldn’t get carried away with this, otherwise you’ll have to wait a long time for a response. However, even when using a specific server as hosting, even its owner can find out the recommended settings.

    Conclusion

    As you can already understand, the error code 504 itself is not critical. And this in no way can indicate irregularities in work operating system(unless there is a problem with viruses). In fact, the whole problem lies mainly only in remote resources who may not be able to respond on time. But there is nothing wrong with this, since in most cases the problem is solved quite simply.

    At the moment, we did not particularly consider the work of hosting services, since the average ordinary user Technical information this kind of thing will say practically nothing. In general, this is not necessary.

    Error 504 Gateway Timeout (time out) is one of the most common. What is 504 Gateway Timeout (time out)? As a rule, this kind of error can occur if a huge number of requests are sent to the server on which some web resource is located, and it simply does not have time to process them, that is, it cannot return within the established time limit HTTP response. As a result, the connection may even be interrupted, and the user will not gain access to the web resource. This is due to the fact that the server does not have time to process old requests, of which there are already many, and new ones appear that get queued and do not have time to be processed.

    How to resolve the 504 Gateway Timeout (time out) error?

    The problem may also lie in the script, which does not have time to cope with the task in the time allotted to it. In most cases, this happens when the script accesses third-party nodes. In order to solve this problem, it is enough to increase the value PHP parameter max_execution_time. If the problem is not solved, then the script itself will have to be optimized in some way so that it can complete the tasks in the specified time.

    Only a server administrator can cope with this pressing problem and must increase its performance several times. The plan can only be realized if the number of random access memory computer, and also change the processor to a more powerful one. In addition, you will need to increase the number of httpd processes directly in the Apache environment. It may also happen that the site will have to “move” to another hosting. Such a need will arise only if the site is located on a regular virtual hosting, the administrator of which either will not respond to requests, or refuses to help, or if he is unable to solve such a problem.

    There is another solution that may appeal to most users. This option involves optimizing the site itself. That is, the site administrator will need to optimize scripts, SQL queries and much more so that they can be executed in less time.