Copied RSS Feed

Syncfusion

How to Solve 504 Gateway Time-Out Errors with Azure Application Gateway

When a browser attempts to load a website, a request is typically made to a web server. An HTTP 504 error code is sent to the browser when the request takes too long to complete. This error might be temporary due to heavy traffic to the website, or it might be due to a resource or request taking too much time to load.

One of our previous articles, 8 Common HTTP Error Codes and Their Possible Fixes, explains a 504 gateway time-out error, its causes, and possible fixes.

This blog will explain how to resolve a 504 gateway time-out error in Azure Application Gateway (AAG) caused by an application error or performance issues.

Azure Application Gateway

As per Microsoft, AAG is a web traffic load balancer enabling us to manage web application traffic. The following features of AAG make it a practical and universally available load balancer:

  • Secure sockets layer (SSL/TLS) termination
  • Autoscaling
  • Web application firewall
  • URL-based routing
  • Multiple-site hosting
  • Redirection
  • Connection draining

AAG has proven very useful with the increased usage of Azure resources for applications. Check the AAG overview documentation for detailed explanations of its other features.

What does the 504 error look like, and what is its cause?

A user receives a 504 error in their browser when there is a long-running request related to the site accessed or some action that the user has performed in the web application. The issue in the browser looks like this:

504 Gateway Time-Out Error

The cause of this error is that AAG has not received a timely response from the application server. The gateway waits for the response, and if it does not receive one within the time-out period, it throws the 504 error.

How to fix the issue

Since we are concentrating on an issue with the application code, we can address the time-out issue by increasing the AAG request time-out period gradually until we can use the application and perform the request successfully. By default, the AAG request time-out period is 20 seconds.

For example, let’s say we are trying to retrieve data for a data grid control, and it takes 30 seconds to process this request. We get a 504-gateway time-out error because the time-out period is 20 seconds. If we increase the time-out period to 40 seconds, the page will load adequately without any problems.

How to increase the request time-out period?

Follow these steps to increase the request time-out period to fix the 504-gateway time-out error:

  1. First, log in to the Azure Portal.
  2. Search for and select the Application Gateways option, which will display the list of application gateways.
  3. Navigate to the required app gateway for which you need to increase the request time-out period.
  4. Find and click on the Backend settings option in the Settings section at the left panel of the page. Refer to the following image.
  5. Under the Backend settings page, select the required backend setting where you need to configure the request time-out period.
  6. Now, increase the value provided in the Request time-out field to the desired period in seconds. This will be the number of seconds the application gateway waits to receive a response from the backend server. Refer to the following image.
  7. Save your changes after modifying the request time-out settings.

Note: Set the request time-out period to an appropriate value based on your app’s requirements or the issue you are facing.

Conclusion

Thank you for reading this blog. I hope that you gained a better understanding of why the 504 gateway time-out issue occurs when using Azure Application Gateway, and that you now have the knowledge to solve the problem quickly.

Additionally, I would like to bring to your attention the recent release of Essential Studio® 2023 Volume 2. You can explore all of the new features in our Release Notes and the What’s New pages, and even try the new features out for yourself with a free trial.

Should you have any further questions, please don’t hesitate to ask. You can leave your inquiries in the comments section below, or reach out to us through our support forumsupport portal, or feedback portal. We are always here to assist you.

Related blogs

Meet the Author

Shriram Sankaran

Shriram Sankaran is a product manager at Syncfusion and has been working on business applications using Syncfusion controls. He has experience in ASP.NET, C#, Angular and SQL Server.