What Do I Do If Could Not Retrieve Mirrorlist Is Displayed in CentOS Yum?

Mondo Technology Updated on 2024-01-29

On CentOS, the error message "could not retrieve mirrorlist" is displayed when the yum command is used is usually caused by yum being unable to obtain the image list of the repositories. This may result in the system not being able to update the software or install new software.

To solve this problem, you can try the following methods:

1.Check your network connection: First, make sure that your system is connected to the internet and that the network connection is working. You can check if the internet connection is working by trying to use your browser or ping the command.

2.Check the yum configuration: Open etc yumrepos.d directory and check the repo file in it, such as centos-baserepo。Check whether the baseurl and mirrorlist are correctly set. If you are using MirrorList, you can comment out the MirrorList line and set it to baseurl instead.

3.Clear Cache: Sometimes the yum cache can be corrupted causing problems, you can try to clear the yum cache and rebuild it using the following command:

sudo yum clean all

4.Check the DNS settings: Make sure that the DNS settings of the system are correct, you can edit etc resolvconf file to check and modify DNS settings.

5.Use a domestic image source: If none of the above methods solve the problem, you can try to use a domestic image source, such as the YUM image source provided by Alibaba Cloud and Huawei Cloud, which is usually more stable.

If you still can't solve the problem after trying the above methods, it is recommended to search the search engine to find the specific error information for in-depth troubleshooting and resolution.

Houlang Cloud provides cloud servers in Hong Kong and the United States, providing high-quality lines, high-speed and stable network environment, and there are also free trial services, so that you can better experience their products. You can visit Houlangyun's official IDCnet for more details.

Related Pages