The website running on the Linux instance cannot be accessed because TCP port 80 and the web service are unavailable

Note The following steps use the CentOS 7 operating system as an example. For specific operations, please refer to your actual operating system.

1. TCP port 80 is not available

1.1 Connect to the Linux instance remotely.

1.2 Execute the following command to check whether TCP port 80 is monitored.

netstat -an | grep 80

The display is as follows. If any of the following results are returned, it means that the web service on TCP port 80 has been started, that is, the check is normal. If there is an exception, see Web Service Unavailable for handling.

Explanation If the local machine monitors, the external network cannot access the web service, and only the local machine can access it. Change it to the whole network monitor.

1.3 Check whether the TCP port 80 is released and whether the connection is normal.

a. Check whether the instance security group allows TCP port 80. If not, you need to add security group rules.

b. Check whether the firewall of the instance operating system is enabled. If it is enabled, it is recommended to disable the firewall and use the security group instead.

c. Use the telnet and traceroute commands to trace the connectivity of TCP port 80.

1.4 Check whether the bandwidth of the cloud server is sufficient.

If not, try to upgrade the instance bandwidth. For details, see Modifying Bandwidth Configuration.

2. The web service is unavailable

2.1 Remotely connect to the Linux instance.

2.2 Check the web service log.

• Execute the following command to check the Apache error log.

You can troubleshoot problems based on error log analysis.

CentOS or Alinux:

less /var/log/httpd/error_log

less /var/log/apache2/error.log

• Execute the following command to check the error log of Nginx.

You can troubleshoot problems based on error log analysis.

less /var/log/nginx/error_log

2.3 Execute the top command to view the running status of the instance.

You need to check whether the process is abnormal, as shown below.

0.01, 0.02, and 0.03 in the load average parameter represent the average system load from 1 minute ago, 5 minutes ago, and 15 minutes ago to the present. Generally, if this value divided by the number of logical CPUs is greater than 5 (the specific value depends on the actual server CPU processing capacity and system usage), it means that the system is overloaded. At this point, you can view the PID with higher %CPU in the process list, locate the abnormal process, that is, the value of the COMMAND parameter, and then handle the exception according to the actual situation of your system.

2.4 View instance monitoring information on the console.

• Check whether the CPU and memory of the instance are sufficient. If not, refer to the Troubleshooting Ideas for Troubleshooting High CPU Usage in the ECS Linux System.

• Check whether the instance bandwidth is sufficient. If not, try to upgrade the instance bandwidth.

2.5 Execute the following command to check whether there are too many TCP connections on port 80 of the instance.

netstat -anp |grep 80 |grep tcp
The display example is as follows.

2.6 Execute the following command to count all TCP connections.

netstat -anp |grep tcp |wc -l

2.7 Compare the number of all TCP connections with the maximum value of the net.ipv4.tcp_max_tw_buckets parameter in the /etc/sysctl.conf configuration file. If the number of all TCP connections exceeds the maximum value, perform the following operations:

a. Execute the vi /etc/sysctl.conf command, edit the /etc/sysctl.conf configuration file, and query the net.ipv4.tcp_max_tw_buckets parameter.

If it is confirmed that the number of TCP connections is very high and it is easy to exceed the limit, then increase the net.ipv4.tcp_max_tw_buckets parameter value according to the actual situation.

b. Execute the sysctl -p command to make the configuration take effect.

Related Articles

Explore More Special Offers

  1. 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

phone Contact Us