ubuntu 执行apt-get update报错Failed to fetch

在ubuntu下执行sudo apt-get update时,经常会遇到报错:

Err http://security.ubuntu.com precise-security InReleaseErr http://security.ubuntu.com precise-security Release.gpg  Temporary failure resolving ‘security.ubuntu.com‘Err http://cn.archive.ubuntu.com precise InReleaseErr http://cn.archive.ubuntu.com precise-updates InReleaseErr http://cn.archive.ubuntu.com precise-backports InReleaseErr http://cn.archive.ubuntu.com precise Release.gpg  Temporary failure resolving ‘cn.archive.ubuntu.com‘Err http://cn.archive.ubuntu.com precise-updates Release.gpg  Temporary failure resolving ‘cn.archive.ubuntu.com‘Err http://cn.archive.ubuntu.com precise-backports Release.gpg  Temporary failure resolving ‘cn.archive.ubuntu.com‘Reading package lists... DoneW: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/precise/InRelease  W: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/precise-updates/InRelease  W: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/precise-backports/InRelease  W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/InRelease  W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/Release.gpg  Temporary failure resolving ‘security.ubuntu.com‘W: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/precise/Release.gpg  Temporary failure resolving ‘cn.archive.ubuntu.com‘W: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/precise-updates/Release.gpg  Temporary failure resolving ‘cn.archive.ubuntu.com‘W: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/precise-backports/Release.gpg  Temporary failure resolving ‘cn.archive.ubuntu.com‘W: Some index files failed to download. They have been ignored, or old ones used instead.

一般都会推荐使用国内的镜像源,比如163或者阿里云的镜像服务器 
将下列文本添加到/etc/apt/sources.list文件里

deb http://mirrors.aliyun.com/ubuntu/ raring main restricted universe multiverse  deb http://mirrors.aliyun.com/ubuntu/ raring-security main restricted universe multiverse  deb http://mirrors.aliyun.com/ubuntu/ raring-updates main restricted universe multiverse  deb http://mirrors.aliyun.com/ubuntu/ raring-proposed main restricted universe multiverse  deb http://mirrors.aliyun.com/ubuntu/ raring-backports main restricted universe multiverse  deb-src http://mirrors.aliyun.com/ubuntu/ raring main restricted universe multiverse  deb-src http://mirrors.aliyun.com/ubuntu/ raring-security main restricted universe multiverse  deb-src http://mirrors.aliyun.com/ubuntu/ raring-updates main restricted universe multiverse  deb-src http://mirrors.aliyun.com/ubuntu/ raring-proposed main restricted universe multiverse  deb-src http://mirrors.aliyun.com/ubuntu/ raring-backports main restricted universe multiverse  

但是执行sudo apt-get update仍然报错,问题在于DNS没有配置好。 
解决方法:

sudo vi /etc/resolv.conf

添加

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTENnameserver 127.0.1.1#这里用的是阿里云的DNS服务器nameserver 223.5.5.5  nameserver 223.6.6.6

之后执行sudo apt-get update就正常了。

参考: 
ubuntu apt-get update 失败解决。 
Ubuntu操作系统“Failed to fetch”错误的解决方法

时间: 2024-10-22 02:39:42

ubuntu 执行apt-get update报错Failed to fetch的相关文章

Ubuntu遇到apt-get update报错:"E: Could not get lock /var/lib/apt/lists/lock"

sudo apt-get update报错:"E: Could not get lock /var/lib/apt/lists/lock" 出现此问题的原因可能是有另外一个程序在运行,导致资源被加锁,不可用.导致资源被锁的原因可能是上次更新源的操作没有完成! 从上图可以看出,报错的内容是不能获取那个路径下的 lock,咱们就应该删除哪个lock. 删除之后再执行 sudo apt-get update 操作,成功! 原文地址:https://www.cnblogs.com/skzxc/

mysql执行update报错1175解决方法

mysql执行update报错 update library set status=true where 1=1 Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column To disable safe mode, toggle the option in Preferences -> SQL Queries and

fetch 报错 Failed to execute 'fetch' on 'Window': Request with GET/HEAD method cannot have body.

TypeError: Failed to execute 'fetch' on 'Window': Request with GET/HEAD method cannot have body. 在"窗口"上执行"取"失败:GET / get方法的请求不能有正文. GET requests can't have a request body, you can't make them have one. GET requests only retrieve data,

Vue.js报错Failed to resolve filter问题原因

Vue.js报错Failed to resolve filter问题原因 金刚 vue Vue.js js javascript 之前使用vue.js写分页功能时,写了一个过滤器,发现一个比较奇怪的错误. console控制台调试的时候 提示错误消息: Failed to resolve filter: HomePage console错误信息.jpg 我原来的写法: 原来的错误写法.jpg 错误原因 经过自己的摸索,后来发现竟然是代码顺序错误问题... 由于先执行的pageList,后执行的V

mvn install 报错Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2 错误: 找不到符号

报错信息 在Eclipse中执行mvn install时,console端显示如下报错信息: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project ERP: Compilation failure: Compilation failure: [ERROR] \test01\src\main\java\HStyl

记几个rac安装执行root.sh的报错

这次在客户现场进行安装,由于实现并没有和硬件的人协调好,导致安装过程中环境出现各种问题,在这一次安装中基本上见到了所有报错,还包括主机频繁重启,以及配置信息丢失等问题, 以下为在安装rac的过程中,执行root.sh脚本报错的三个问题: /u01/11.2.0/grid/bin/srvctl start nodeapps -n RAC01 ... failed FirstNode configuration failed at  /u01/11.2.0/grid/crs/install/crsc

解决;R语言使用sqldf库是报错"Failed to connect to database: Error: Access denied for user '..'@'localhost' (using password: NO) Error in !dbPreExists : invalid argument type"

原因:在使用sqldf时,不需要加载RMySQL库 解决方案:在控制台执行释放RMySQL库加载 detach("package:RMySQL", unload=T); 解决;R语言使用sqldf库是报错"Failed to connect to database: Error: Access denied for user '..'@'localhost' (using password: NO) Error in !dbPreExists : invalid argume

Jpa自定义查询报错(Failed to convert from type [java.lang.Object[]] to type)

Jpa自定义查询报错 问题背景 今天遇到一个奇怪的报错"Failed to convert from type [java.lang.Object[]] to type",这个报错,百度上也是很少的,恰恰是这样的问题,引起我了解决的欲望.先看看报错: org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.Object[]] to type [o

git push 报错:failed to push some refs to '[email protected]:devops/thor.git'

error: failed to push some refs to '[email protected]:devops/thor.git' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing