HTTP status 504 gateway timeout – Quick remedies for you

Table of Contents

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 1 onlyhost ’ Engineers fix it.



What is a 504 Gateway Timeout Error

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,

  1. DNS Errors.
  2. Bad timeout Configuration.
  3. 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.

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;


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.]



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.

Leave a Comment

Your email address will not be published. Required fields are marked *

Social Share


Cheapest Web Hosting

Fasters Web Hosting Promo
Scroll to Top

Launch your Website at RS599

Create a professional website yourself with our domain hosting combo. Get Extra benefits at this Year end Sale with 10% OFF and Enjoy Amazing Deels on Shared Hosting!

Starting at Only RS599/Year

Year End Sale


Use Code STARTBIZ at Checkout.

Create an earning opportunity with A Web Hosting Business

Become reseller and start reselling domains, web hosting, ssl certificates and More.

45% OFF

Starting at RS399/Month


Use coupon: at the checkout.