apt get update无法正常使用

解决方法参考博客

[问题描述]

前几天执行apt相关命令(如apt-get update),都会长时间停在``等待报头'',超时后,显示连接超时。

换了快速指南上提到的所有源,但是依然没有效果

今天执行的时候,打印出了如下信息:

代码: 全选

$ sudo apt-get update
错误 http://archive.ubuntu.com gutsy Release.gpg
无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
错误 http://archive.ubuntu.com gutsy/main Translation-zh_CN
无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
错误 http://archive.ubuntu.com gutsy/restricted Translation-zh_CN
无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
错误 http://archive.ubuntu.com gutsy/universe Translation-zh_CN
无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
错误 http://archive.ubuntu.com gutsy/multiverse Translation-zh_CN
无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
错误 http://archive.ubuntu.com gutsy-security Release.gpg
无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
错误 http://archive.ubuntu.com gutsy-security/main Translation-zh_CN
无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
错误 http://archive.ubuntu.com gutsy-security/restricted Translation-zh_CN
无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
错误 http://archive.ubuntu.com gutsy-security/universe Translation-zh_CN
无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
错误 http://archive.ubuntu.com gutsy-security/multiverse Translation-zh_CN
无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
错误 http://archive.ubuntu.com gutsy-updates Release.gpg
无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
错误 http://archive.ubuntu.com gutsy-updates/main Translation-zh_CN
无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
错误 http://archive.ubuntu.com gutsy-updates/restricted Translation-zh_CN
无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
错误 http://archive.ubuntu.com gutsy-updates/universe Translation-zh_CN
无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
错误 http://archive.ubuntu.com gutsy-updates/multiverse Translation-zh_CN
无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
错误 http://archive.ubuntu.com gutsy-proposed Release.gpg
无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
错误 http://archive.ubuntu.com gutsy-proposed/main Translation-zh_CN
无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
错误 http://archive.ubuntu.com gutsy-proposed/restricted Translation-zh_CN
无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
错误 http://archive.ubuntu.com gutsy-proposed/universe Translation-zh_CN
无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
错误 http://archive.ubuntu.com gutsy-proposed/multiverse Translation-zh_CN
无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
错误 http://packages.medibuntu.org gutsy Release.gpg
无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
错误 http://packages.medibuntu.org gutsy/free Translation-zh_CN
无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
错误 http://packages.medibuntu.org gutsy/non-free Translation-zh_CN
无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
错误 http://archive.ubuntu.com gutsy-backports Release.gpg
无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
错误 http://archive.ubuntu.com gutsy-backports/main Translation-zh_CN
无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
错误 http://archive.ubuntu.com gutsy-backports/restricted Translation-zh_CN
无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
错误 http://archive.ubuntu.com gutsy-backports/universe Translation-zh_CN
无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
错误 http://archive.ubuntu.com gutsy-backports/multiverse Translation-zh_CN
无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
无法下载 http://archive.ubuntu.com/ubuntu/dists/gutsy/Release.gpg 无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
无法下载 http://archive.ubuntu.com/ubuntu/dists/gutsy/main/i18n/Translation-zh_CN.bz2 无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
无法下载 http://archive.ubuntu.com/ubuntu/dists/gutsy/restricted/i18n/Translation-zh_CN.bz2 无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
无法下载 http://archive.ubuntu.com/ubuntu/dists/gutsy/universe/i18n/Translation-zh_CN.bz2 无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
无法下载 http://archive.ubuntu.com/ubuntu/dists/gutsy/multiverse/i18n/Translation-zh_CN.bz2 无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
无法下载 http://archive.ubuntu.com/ubuntu/dists/gutsy-security/Release.gpg 无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
无法下载 http://archive.ubuntu.com/ubuntu/dists/gutsy-security/main/i18n/Translation-zh_CN.bz2 无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
无法下载 http://archive.ubuntu.com/ubuntu/dists/gutsy-security/restricted/i18n/Translation-zh_CN.bz2 无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
无法下载 http://archive.ubuntu.com/ubuntu/dists/gutsy-security/universe/i18n/Translation-zh_CN.bz2 无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
无法下载 http://archive.ubuntu.com/ubuntu/dists/gutsy-security/multiverse/i18n/Translation-zh_CN.bz2 无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
无法下载 http://archive.ubuntu.com/ubuntu/dists/gutsy-updates/Release.gpg 无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
无法下载 http://archive.ubuntu.com/ubuntu/dists/gutsy-updates/main/i18n/Translation-zh_CN.bz2 无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
无法下载 http://archive.ubuntu.com/ubuntu/dists/gutsy-updates/restricted/i18n/Translation-zh_CN.bz2 无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
无法下载 http://archive.ubuntu.com/ubuntu/dists/gutsy-updates/universe/i18n/Translation-zh_CN.bz2 无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
无法下载 http://archive.ubuntu.com/ubuntu/dists/gutsy-updates/multiverse/i18n/Translation-zh_CN.bz2 无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
无法下载 http://archive.ubuntu.com/ubuntu/dists/gutsy-proposed/Release.gpg 无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
无法下载 http://archive.ubuntu.com/ubuntu/dists/gutsy-proposed/main/i18n/Translation-zh_CN.bz2 无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
无法下载 http://archive.ubuntu.com/ubuntu/dists/gutsy-proposed/restricted/i18n/Translation-zh_CN.bz2 无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
无法下载 http://archive.ubuntu.com/ubuntu/dists/gutsy-proposed/universe/i18n/Translation-zh_CN.bz2 无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
无法下载 http://archive.ubuntu.com/ubuntu/dists/gutsy-proposed/multiverse/i18n/Translation-zh_CN.bz2 无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
无法下载 http://archive.ubuntu.com/ubuntu/dists/gutsy-backports/Release.gpg 无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
无法下载 http://archive.ubuntu.com/ubuntu/dists/gutsy-backports/main/i18n/Translation-zh_CN.bz2 无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
无法下载 http://archive.ubuntu.com/ubuntu/dists/gutsy-backports/restricted/i18n/Translation-zh_CN.bz2 无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
无法下载 http://archive.ubuntu.com/ubuntu/dists/gutsy-backports/universe/i18n/Translation-zh_CN.bz2 无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
无法下载 http://archive.ubuntu.com/ubuntu/dists/gutsy-backports/multiverse/i18n/Translation-zh_CN.bz2 无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
无法下载 http://packages.medibuntu.org/dists/gutsy/Release.gpg 无法连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
无法下载 http://packages.medibuntu.org/dists/gutsy/free/i18n/Translation-zh_CN.bz2 无法连接 上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
无法下载 http://packages.medibuntu.org/dists/gutsy/non-free/i18n/Translation-zh_CN.bz2 无法 连接上 localhost:4001 (127.0.0.1)。 - connect (111 Connection refused)
正在读取软件包列表... 完成
W: 有一些索引文件不能下载,它们可能被忽略了,也可能转而使用了旧的索引文件。
$

上网google,发现了类似的问题:

viewtopic.php?t=80237&sid=a94bef5d612a8 ... 2c437fce7f

[网络环境]

普通家庭网络,通过路由上网,路由器通过PPPoE与因特网连接。没有对外连接的限制。未开防火墙。没有代理

[尝试措施]

o 把source.list中的域名部分,换成了IP,即,把archive.ubuntu.com换成了91.189.88.45,症状依旧

o 禁用了IPv6,症状依旧

[相关资料]

source.list放在了附件中

该问题已经解决,解决方案如下

[解决方案]

感谢BigSnake.NET

首先检测是否设置了http代理。检测方法:

代码: 全选

 env | grep -i proxy

如果设置了代理,会出现:

代码: 全选

$ env | grep -i proxy
http_proxy=http://localhost:4001
HTTP_PROXY=http://localhost:4001
$

此时,删除这两个环境变量,bash下输入:

代码: 全选

unset http_proxy
unset HTTP_PROXY

最后,从配置文件里面把这两个环境变量彻底删除。通常会在/etc/environment里面

代码: 全选

sudo gedit /etc/environment

删除包含

http_proxy

HTTP_PROXY

的行

最新文章

  1. mysql登录不了及修改密码
  2. extJS起步
  3. InterBase数据库迁移到MySQL(数据导出)
  4. 学习mongo系列(八)密码与权限
  5. (转载)iOS系统Crash文件分析方法
  6. kFreeBSD当前可以做的和不能做的
  7. SQL server数据类型、增删改查
  8. Windows 7无线网卡启用wifi共享蓝屏!
  9. OPENSSL安装 以及使用openssl中的AES加密和解密
  10. 偶遇mysql外键不好使
  11. HW2.14
  12. config 数据库字符串的读取、修改 分类: WebForm 2014-12-16 10:24 203人阅读 评论(0) 收藏
  13. WPF中的布局控件(转)
  14. python idle 错误 subprocess didn't make connection
  15. Request.UrlReferrer为空的问题
  16. java 10 中 var关键字用法
  17. angularjs简单介绍和特点
  18. Linux命令(九)查找文件find
  19. 编译openwrt时报错:fstools-2018-01-02-11efbf3b/libfstools/overlay.c: At top level: cc1: error: unrecognized command line option '-Wno-format-truncation' [-Werror]
  20. mysql 优化2

热门文章

  1. linux文件与目录管理命令(ubuntu)
  2. ubuntu 上已经安装libxml2还提示需要reinstall的解决方法
  3. Java-小技巧-005-double类型保留两位小数4种方法
  4. PHP命名空间-总结
  5. jenkins用户管理(Role-based Authorization Strategy插件使用)
  6. pytorch rnn
  7. MySQL 参数
  8. 20165324 Java实验四 Android程序设计
  9. linux安装以及相关配置
  10. 微信公众号JSAPI支付