Troubleshooting Yum Installation Error: Could not retrieve mirrorlist CentOS7
If you're a software developer and not a system engineer, and you're trying to install the Zabbix agent on a CentOS7 system, you might encounter the following problem:
Understanding the error
The error message indicates that Yum was unable to retrieve the mirrorlist for CentOS7. This can happen due to various reasons, such as network issues, firewall settings, or DNS problems. In this case, the error message also indicates that the system was unable to connect to the IPv6 address of the mirrorlist server.
Checking network connectivity
The first step in troubleshooting this issue is to check the network connectivity of the system. You can use the ping command to check if the system can reach the mirrorlist server:
If the ping command fails, it could indicate a network issue. You can also try to access the mirrorlist server using a web browser to see if you can reach it:
http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock
If you can access the mirrorlist server using a web browser, but not using the yum command, it could indicate a problem with the system's DNS settings.
Checking DNS settings
You can check the system's DNS settings using the nmcli command:
In this example, the system is using the OpenDNS servers as its DNS servers. You can try to change the DNS servers to Google's DNS servers by editing the /etc/resolv.conf file:
After changing the DNS servers, try to run the yum command again.
Checking firewall settings
If the network connectivity and DNS settings are correct, the next step is to check the firewall settings. By default, CentOS7 uses the firewalld service to manage the firewall. You can check the status of the firewall using the firewall-cmd command:
If the firewall is running, you can check the firewall rules using the firewall-cmd --list-all command. Make sure that the firewall allows incoming traffic on the necessary ports for the Zabbix agent.
Disabling IPv6
If none of the above steps resolve the issue, you can try disabling IPv6 on the system. To do this, edit the /etc/sysctl.conf file and add the following line:
After adding the line, save the file and run the sysctl -p command to apply the changes. Then, try to run the yum command again.
- Check network connectivity using the
pingcommand - Check DNS settings using the
nmclicommand - Check firewall settings using the
firewall-cmdcommand - Disable IPv6 by editing the
/etc/sysctl.conffile