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
- Web application firewall
- URL-based routing
- Multiple-site hosting
- 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:
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.
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 forum, support portal, or feedback portal. We are always here to assist you.