Troubleshoot "Connection timed out" when accessing the Metaserver from a Linux instance
Fix the "curl: (7) Failed to connect to 100.100.XX.XX port 80: Connection timed out" error by resetting DHCP or disabling the firewall.
Symptom
Running a curl command on a Linux instance to connect to the Metaserver at 100.100.XX.XX fails with the following error:
curl: (7) Failed to connect to 100.100.XX.XX port 80: Connection timed out
The connection to port 80 at the specified IP address timed out.
If a Linux instance cannot access the Metaserver, initialization operations such as key pair configuration, hostname setup, and hosts setup may fail.
Cause
The issue typically occurs because the network environment of the Linux instance prevents connections to destination IP addresses. Common causes include:
-
Abnormal network configurations prevent connections to the Metaserver. Reset the network configuration to DHCP. See Reset the network configuration to DHCP.
-
Firewall rules block access to
100.100.**.**. Temporarily disable the firewall to verify. See Disable the system firewall.
Solution
Reset the network configuration to DHCP
This example uses a Red Hat series Linux instance. For other distributions, see How to configure the network as DHCP in a Linux image.
-
Modify the network configuration file:
sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0 -
Set the following network configurations:
BOOTPROTO=dhcp DEVICE=eth0 ONBOOT=yes STARTMODE=auto TYPE=Ethernet USERCTL=no -
Press
Escto exit Insert mode. Enter:wqand press Enter to save and close the file. -
Restart the network service.
-
If the instance runs CentOS 6 or Red Hat 6:
sudo service network restart -
If the instance runs CentOS 7, Red Hat 7, Anolis 7, or Alibaba Cloud Linux 2:
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:
-
Reload all NIC configurations:
sudo nmcli c reload -
Enable NICs:
sudo nmcli d connect eth0
-
-
Disable the system firewall
Firewall commands vary by Linux distribution. Adjust as needed.
CentOS 5 and CentOS 6
Manage the firewall in CentOS 5 and CentOS 6:
-
Enable the firewall:
sudo service iptables start -
Disable the firewall:
sudo service iptables stop -
Check the firewall status:
sudo service iptables status
CentOS 7, Red Hat 7, and Alibaba Cloud Linux 2
Manage the firewall in CentOS 7, Red Hat 7, and Alibaba Cloud Linux 2:
-
Enable the firewall:
sudo systemctl start firewalld.service -
Disable the firewall:
sudo systemctl stop firewalld.service -
Check the firewall status:
sudo firewall-cmd --state
Ubuntu
Manage the firewall in Ubuntu:
-
Enable the firewall:
sudo ufw enable -
Disable the firewall:
sudo ufw disable -
Check the firewall status:
sudo ufw status
Debian
Debian has no firewall installed by default. If a firewall is installed, delete all rules to remove traffic blocking.
Back up the rules before deleting them.
-
Back up firewall rules:
touch [$Iptables] sudo iptables-save > [$Iptables]Note[$Iptables]specifies the backup file path. -
Delete all firewall rules:
sudo iptables -F