How to deal with connect upstream time out error?
Problem Description
When using Nginx to access the webpage, a "502" error is prompted, as shown in the figure:
At this time, check the following, and find that the "connect upstream time out" error appears in the Nginx service log:
1. Check the PHP-FPM process and find that the PHP-FPM process is running normally, as shown in the figure.

2. Check the Nginx service log, and find that the "connect upstream time out" error appears in the Nginx service log, as shown in the figure.
connect upstream time out
Problem Causes
The PHP-FPM service starts normally and the listening port (127.0.0.1:9000) has been set, but the local loopback network card (lo) is not started, causing this problem.
Solution
You need to check whether the local loopback network card (lo) is started normally. If not, you need to start it and then visit the website again. The operation steps are as follows:
1. Remotely connect to the ECS instance.
2. Check whether the local loopback network card (lo) starts normally.
a. Run the ifconfig -a command to check the network card information of the current system.
When the status of the local loopback network card (lo) is not started, as shown in the figure, you need to start the local loopback network card (lo).
b. Execute the ifup ifcfg-lo command to start the local loopback NIC (lo).
When the status of the local loopback network card (lo) is RUNNING, it means that the local loopback network card (lo) has been successfully started, as shown in the figure.
3. Check the local loopback network card (lo) configuration file.
a. Run the following command to edit the configuration file of the local loopback NIC (lo).
You need to execute the corresponding command according to your actual operating system. Common operating system commands are as follows:
• CentOS 7 or Alibaba Cloud Linux 2/3
vim /etc/sysconfig/network-script/ifcfg-lo
• Ubuntu 16.04
vim /etc/network/interfaces
• Ubuntu 18.04 and above
vim /etc/netplan/50-cloud-init.yaml
Take the CentOS operating system as an example. If the value of the ONBOOT parameter is no in the command output, you need to change ONBOOT=no to ONBOOT=yes, as shown in the figure.
Note If there is no configuration related to ONBOOT parameters in your operating system, you only need to check that the configuration file is correct after the NIC starts normally.
b. Enter :wq and press Enter to save and close the configuration file.
c. Execute the systemctl restart network command to restart the network.
4. Re-use Nginx to access the webpage.
Related Articles
-
A detailed explanation of Hadoop core architecture HDFS
Knowledge Base Team
-
What Does IOT Mean
Knowledge Base Team
-
6 Optional Technologies for Data Storage
Knowledge Base Team
-
What Is Blockchain Technology
Knowledge Base Team
Explore More Special Offers
-
Short Message Service(SMS) & Mail Service
50,000 email package starts as low as USD 1.99, 120 short messages start at only USD 1.00