Nginx Timeout Error: upstream timed out (110: Connection timed out) while reading response header from ups…

Error content

We can see it in error. Log

Error: upstream timed out (110: Connection timed out) while reading response header from upstream

Cause of error

From the error log, we can know that the error is due to the timeout of nginx agent to get the return value of upstream server. What causes this problem

It takes a long time for the back-end to process the request

It may also be a network problem between the proxy server and the upstream server

We find out the problem by locating the wrong URL, and finally determine that the problem is due to the long time of back-end processing of the request. Then the solution can be that developers optimize the interface, or we can set the timeout time longer through nginx

Error resolution

nginx timeout setting

Official website link: http://nginx.org/en/docs/http/ngx_ http_ proxy_ module.html#proxy_ read_ timeout

Syntax: proxy_ read_ timeout time;
Default: proxy_ read_ timeout 60s;
Context: http,server,location
Defines a timeout for reading a response from the proxied server. The timeout is set only between two successive read operations, not for the transmission of the whole response. If the proxied server does not transmit anything within this time, the connection is closed.

proxy_ read_ Timeout parameter. This instruction refers to the time-out for two successful read operations from the upstream server. It means that after 60 seconds of successful read operation from the upstream server, if there is no successful read operation from the upstream server, the connection will be closed

The default value is 60s. We can set it to 240s or 300s. To deal with the problem of slow processing of requests by upstream servers

In the configuration file of nginx, add

proxy_read_timeout 240s; 

Similar Posts: