All Products
Search
Document Center

:What do I do if I cannot run a curl command to access the Metaserver from a Linux instance and the "curl: (7) Failed to connect to 100.100.XX.XX port 80: Connection timed out" error message appears?

Last Updated:Jan 29, 2024

This topic describes the cause of and solution to the following issue: You cannot run a curl command to access the Metaserver from a Linux Elastic Compute Service (ECS) instance and the "curl: (7) Failed to connect to 100.100.XX.XX port 80: Connection timed out" error message appears.

Problem description

When you run a curl command on a Linux instance to connect to the Metaserver (metadata server) by using the IP address 100.100.XX.XX, the connection fails and the following error message appears:

curl: (7) Failed to connect to 100.100.XX.XX port 80: Connection timed out

The error message indicates that the connection to port 80 at the preceding IP address timed out and failed.

Note

If a Linux instance cannot access the Metaserver, specific initialization operations on the instance may fail, such as key pair configuration, hostname initialization, and hosts initialization.

Cause

In most cases, the issue occurs because exceptions exist in the network environment of the Linux instance and causes the instance to fail to establish network connections to destination IP addresses. The following exceptions may exist in the network environment of the Linux instance:

  • Abnormal network configurations: cause the Linux instance to fail to establish network connections. As a result, the instance cannot connect to the Metaserver. To resolve the issue, reset the network configuration to Dynamic Host Configuration Protocol (DHCP). For more information, see the Reset the network configuration to DHCP section in this topic.

  • Firewall rules that block access to the Metaserver: cause the Linux instance to fail to access the Metaserver by using 100.100.**.**. You can check the system firewall configurations and temporarily disable the system firewall to check whether the firewall configurations cause the Linux instance to fail to access the Metaserver. For more information, see the Disable the system firewall section in this topic.

Solution

Reset the network configuration to DHCP

In this example, a Linux instance that runs a Red Hat series operating system is used to describe how to reset the network configuration to DHCP. For information about how to reset the network configuration to DHCP in other Linux distributions, see How to configure the network as DHCP in a Linux image.

  1. Connect to the Linux instance that runs a Red Hat series operating system.

    For more information, see Connect to a Linux instance by using a password or key.

  2. Run the following command to modify the network configuration file:

    sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0 
  3. Change the following network configurations:

    BOOTPROTO=dhcp
    DEVICE=eth0
    ONBOOT=yes
    STARTMODE=auto
    TYPE=Ethernet
    USERCTL=no
  4. Press the Esc key to exit Insert mode. Enter :wq and press the Enter key to save and close the file.

  5. Restart the network service.

    • If the instance runs CentOS 6 or Red Hat 6, run the following command:

      sudo service network restart
    • If the instance runs CentOS 7, Red H, Anolis 7, or Alibaba Cloud Linux 2, run the following command:

      sudo systemctl restart network
    • If the instance runs CentOS 8, Red Hat 8, Anolis 8, Fedora 33, Fedora 34, Fedora 35, or Alibaba Cloud Linux 3, perform the following operations:

      1. Run the following command to reload all network interface controller (NIC) configurations:

         sudo nmcli c reload
      2. Run the following command to enable NICs:

        sudo nmcli d connect eth0

Disable the system firewall

The commands that are used to enable or disable the system firewall vary based on the Linux distribution. Modify the following commands based on the actual scenarios.

CentOS 5 and CentOS 6

Run the following commands to enable and disable the system firewall and check the status of the system firewall in CentOS 5 and CentOS 6.

  • Enable the system firewall.

    sudo service iptables start
  • Disable the system firewall.

    sudo service iptables stop
  • Check the status of the system firewall.

    sudo service iptables status

CentOS 7, Red Hat 7, and Alibaba Cloud Linux 2

Run the following commands to enable and disable the system firewall and check the status of the system firewall in CentOS 7, Red Hat, and Alibaba Cloud Linux 2.

  • Enable the system firewall.

    sudo systemctl start firewalld.service
  • Disable the system firewall.

    sudo systemctl stop firewalld.service
  • Check the status of the system firewall.

    sudo firewall-cmd --state

Ubuntu

Run the following commands to enable and disable the system firewall and check the status of the system firewall in Ubuntu.

  • Enable the system firewall.

    sudo ufw enable
  • Disable the system firewall.

    sudo ufw disable
  • Check the status of the system firewall.

    sudo ufw status

Debian

By default, no firewall is installed on Debian. If a firewall is installed on Debian, you can delete all firewall rules to remove traffic blocking. Perform the following operations.

Important

Before you delete all firewall rules, back up the rules.

  1. Run the following commands to back up firewall rules:

    touch [$Iptables]
    sudo iptables-save > [$Iptables]
    Note

    [$Iptables] specifies the directory in which you want to save the firewall rule backup file.

  2. Run the following command to delete all firewall rules:

    sudo iptables -F