Website errors are difficult to decode especially when it shows strange error codes.
A typical example is 504 gateway timeout which occurs due to bad DNS server settings, Firewall settings, timeout settings and much more.
That’s why, we often get requests from our customers to fix 504 gateway timeout error as part of our Technical Support Services.
Today, let’s understand what is 504 gateway timeout error and reasons on why this error occurs, also the way Bobcares’ Engineers fix it.
What is a 504 Gateway Timeout Error
A 504 gateway timeout is HTTP status code, indicating an error on the server side.
Also, it indicates that a web server trying to load a page has not received a timely response from another server. Usually, this means the other server is down or not functioning properly.
There are several reasons why the server was unable to complete the request within the given time frame. This includes,
- DNS Errors.
- Bad timeout Configuration.
- Wrong Firewall Settings.
Now, let’s see reasons for 504 gateway timeout error and how our Support Engineers fixed them.
DNS Error
A 504 gateway timeout error may occur due to the DNS issue, such as the domain’s A record is not pointing to the correct IP.
For example, one of our customers migrated the server to a new host. After that, he was getting 504 gateway timeout page on his website.
1. Then our Support Engineers checked the DNS settings by using dig command.
dig bobcares.com
2. From that, we found that the domain did not have a proper A record.
3. We updated the correct IP address for A record in WHM >> Home >> DNS Functions >> Edit DNS Zone.
Also, we asked customers to wait up to 48 hours for the DNS record to propagate completely.
That fixed the issue and the customer could access the site.
Improper Firewall Configuration
The bad configuration of firewall settings or certain rules preventing from connection establishment results in 504 gateway timeout error. Because of faulty firewall configuration, it misinterprets the requests from a content delivery network as an attack on the server and rejects them.
Here, our Support Engineers correct the server Firewall in such a way that it does not create a security risk for the server.
Incorrect proxy settings
The incorrect proxy setting may cause 504 gateway timeout error on the client’s side as well as the server’s.
For example in Nginx, our Support Engineers will check the configuration file for the app in /etc/nginx/conf.d/ and ensure that the given domain name is correct.
server {
listen 80;
listen [::]:80;
server_name domain.com;
location / {
proxy_pass http://localhost:3000/;
}
}
In addition, we will check Nginx resource settings in timeout.conf file and ensure that the parameters are set up correctly. Furthermore, if needed we will increase the following values.
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;
PHP Timeout Issue
The PHP timeout issues may cause a 504 timeout error. Again, this error occurs when a single PHP process runs for more than the max_execution_time.
To solve this issue, our Support Engineers have increased the PHP timeout values in the PHP settings on the server.
In Apache on Ubuntu, we took the following steps to edit php.ini for increasing the PHP timeout values.
1. We edited the file php.ini
nano /etc/php5/apache2/php.ini
2. Then, we found the line for “max_execution_time”.
3. We increased the value max_execution_time and saved the changes.
max_execution_time = 30
4. At last, we restarted the service.
service apache2 restart
[Getting 504 gateway timeout” error? We are here to fix it.]
Conclusion
In short, HTTP status code 504 gateway timeout is a server-side error. It occurs when a web server trying to load a page do not receive a timely response from another server.
0 Comments