Nginx upstream timed out error - Fix it Now ?

Nginx upstream timed out error - Fix it Now ?

Nginx upstream timeout error (110: Connection timed out) appears when nginx is not able to receive an answer from the webserver.

Basically, this error happens when PHP FPM service  of the Nginx web server is crashing.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to resolve related Nginx errors.

In this context, we shall look into methods to fix this Nginx error.

Nature of Nginx upstream timed out error

The upstream timeout error generally triggers when the upstream takes too much to answer the request and NGINX thinks the upstream already failed in processing the request.

Some of the common reasons for this error include:

1. Server resource usage

2. PHP memory limits

3. Server software timeouts

How to fix Nginx upstream timed out error?

1. Server resource usage

One of the most common reasons for this error is server resource usage. Often heavy load makes the server slow to respond to requests.

When it takes too much time to respond, in a reverse proxy setup Nginx thinks that the request already failed.

We already have some articles discussing the steps to troubleshoot server load here.

We also make sure that there is enough RAM on the server. 

To check that they use the top, htop or free -m commands.

In addition, we also suggest optimizing the website by installing a good caching plugin. 

This helps to reduce the overall resource usage on the server.

2. PHP memory limits

At times, this error could be related only to specific PHP codes.  Our Support Engineers cross-check the PHP FPM error log in such cases for a more detailed analysis of the error.

Sometimes, PHP would be using too much RAM and the PHP FPM process gets killed. In such cases, we would recommend to make sure that the PHP memory limit is not too high compared to the actual available memory on the Droplet.

For example, if you have 1GB of RAM available your PHP memory limit should not be more than 64MB.

3. Server software timeouts

Nginx upstream errors can also occur when a web server takes more time to complete the request.

By that time, the caching server will reach its timeout values(timeout for the connection between proxy and upstream server).

Slow queries can lead to such problems.

We will fine tune the following Nginx timeout values in the Nginx configuration file:

proxy_connect_timeout 1200s;
proxy_send_timeout 1200s;
proxy_read_timeout 1200s;
fastcgi_send_timeout 1200s;
fastcgi_read_timeout 1200s;

Once the timeout values are added, need to reload Nginx to save these parameters.

[Need urgent assistance in fixing Nginx errors? We can help you. ]

Who We Are ?

Most prominent, efficient, and well-performing IT companies and software solutions.

Related Posts