Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the troubleshooting method for nginx 504?

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "what is the troubleshooting method of nginx 504". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the troubleshooting method of nginx 504".

Technical background

Under the LNMP environment, the reverse proxy server nginx error log reports a large number of errors, showing 504

504.png

Upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while reading response header from upstream

Theoretical review

Nginx 504 Gateway Time-out means that the requested gateway has not been requested. To put it simply, there is no request for executable PHP-CGI.

In general, when a web application submits a dynamic request, nginx will directly transfer the request to php-fpm, and php-fpm will assign the php-cgi process to process the relevant request, and then return it in turn, and finally nginx will feedback the result to the client browser.

The reasons are listed as follows

1 as the caller, the service provider interface is abnormal, resulting in access timeout. The task assigned by nginx to PHP is not returned for a long time, and nginx directly returns 504. This timeout is difficult to capture in the code logic at the PHP call level, and it is not customary to catch it, leaving it to the framework-level exception catcher.

(2) as a service provider, the time-out of accessing the database by its own service does not return or the business processing at the PHP level is seriously time-consuming, and the program design is unreasonable, resulting in a long delay and timeout.

Fastcgi process

Problem tracking

If a large number of 504 errors occur in the PHP service for a short time, the entire fastcg channel will be congested, and finally the PHP service will fail.

If multiple services are in the form of virtual hosts on the same server, then these services will be affected. The most intuitive foreground experience is slow access speed, or can not be opened directly.

Scheduled tasks, run batches, database batch data update related business is prone to nginx errors.

504 is solved by configuration on the network, which is not recommended under normal circumstances, and priority should be given to the deficiencies in program design and implementation.

Thank you for your reading, the above is the content of "what is the troubleshooting method of nginx 504". After the study of this article, I believe you have a deeper understanding of what the troubleshooting method of nginx 504is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report