[问题]apt无法正常使用[已解决][附解决方法]

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
头像
monnand
帖子: 104
注册时间: 2007-02-16 1:23

[问题]apt无法正常使用[已解决][附解决方法]

#1

帖子 monnand » 2008-01-31 19:06

[问题描述]
前几天执行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_proxyHTTP_PROXY的行

[问题原因]
由于设置了http代理,却没有启动http代理程序。
我这次的原因,是由于安装了anon-proxy所致。

[后续问题]
我看了我的/etc/environment,从注释上看,是anon-proxy修改的配置文件。应该是软件在安装的时候默认配置的问题,不知道这个应该算是bug,还是算是特性。不过个人以为,默认设置应该相对调整一下,免得让人摸不着头脑。(在发帖前,我还特意考虑了一下,有没有装http代理。要不是BigSnake.NET的提醒,我确实没有想到会是由于前几天安装软件引起的)
附件
apt.tar.bz2
我的source.list
(506 Bytes) 已下载 175 次
上次由 monnand 在 2008-01-31 19:45,总共编辑 3 次。
头像
BigSnake.NET
帖子: 12522
注册时间: 2006-07-02 11:16
来自: 廣州
联系:

#2

帖子 BigSnake.NET » 2008-01-31 19:12

ping archive.ubuntu.com

看看
^_^ ~~~
要理解递归,首先要理解递归。

地球人都知道,理论上,理论跟实际是没有差别的,但实际上,理论跟实际的差别是相当大滴。
头像
monnand
帖子: 104
注册时间: 2007-02-16 1:23

#3

帖子 monnand » 2008-01-31 19:15

能够ping通
头像
BigSnake.NET
帖子: 12522
注册时间: 2006-07-02 11:16
来自: 廣州
联系:

#4

帖子 BigSnake.NET » 2008-01-31 19:23

monnand 写了:能够ping通
ping 到什么了, 贴出来
^_^ ~~~
要理解递归,首先要理解递归。

地球人都知道,理论上,理论跟实际是没有差别的,但实际上,理论跟实际的差别是相当大滴。
头像
monnand
帖子: 104
注册时间: 2007-02-16 1:23

#5

帖子 monnand » 2008-01-31 19:24

代码: 全选

$ ping archive.ubuntu.com
PING archive.ubuntu.com (91.189.88.46) 56(84) bytes of data.
64 bytes from lithium.canonical.com (91.189.88.46): icmp_seq=1 ttl=50 time=551 ms
64 bytes from lithium.canonical.com (91.189.88.46): icmp_seq=2 ttl=50 time=572 ms
64 bytes from lithium.canonical.com (91.189.88.46): icmp_seq=3 ttl=50 time=590 ms
64 bytes from lithium.canonical.com (91.189.88.46): icmp_seq=4 ttl=50 time=622 ms
64 bytes from lithium.canonical.com (91.189.88.46): icmp_seq=5 ttl=50 time=573 ms
64 bytes from lithium.canonical.com (91.189.88.46): icmp_seq=6 ttl=50 time=622 ms

--- archive.ubuntu.com ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5316ms
rtt min/avg/max/mdev = 551.884/588.863/622.275/26.118 ms
$   
头像
BigSnake.NET
帖子: 12522
注册时间: 2006-07-02 11:16
来自: 廣州
联系:

#6

帖子 BigSnake.NET » 2008-01-31 19:24

env | grep -i proxy

看看
^_^ ~~~
要理解递归,首先要理解递归。

地球人都知道,理论上,理论跟实际是没有差别的,但实际上,理论跟实际的差别是相当大滴。
头像
monnand
帖子: 104
注册时间: 2007-02-16 1:23

#7

帖子 monnand » 2008-01-31 19:39

汗……多谢提醒……刚刚grep了一下,结果如下:

代码: 全选

$ env | grep -i proxy
http_proxy=http://localhost:4001
HTTP_PROXY=http://localhost:4001
$  
一直以为我这里基本没用过http代理,刚刚仔细想了一下,前几天装了tor,刚刚把privoxy删除,去除了环境变量,一切正常了。
现在把解决方案帖出来:

[解决方案]

感谢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_proxyHTTP_PROXY的行

[后续问题]
我看了我的/etc/environment,从注释上看,是anon-proxy修改的配置文件。应该是软件在安装的时候默认配置的问题,不知道这个应该算是bug,还是算是特性。不过个人以为,默认设置应该相对调整一下,免得让人摸不着头脑。(在发帖前,我还特意考虑了一下,有没有装http代理。要不是BigSnake.NET的提醒,我确实没有想到会是由于前几天安装软件引起的)
moxien
帖子: 145
注册时间: 2006-09-20 14:36

#8

帖子 moxien » 2008-07-03 22:08

装XXX后(晕啊,这个都被河蟹),碰到同样问题了,正在试楼主的方法。先mark一下。
上次由 moxien 在 2008-07-03 22:16,总共编辑 1 次。
moxien
帖子: 145
注册时间: 2006-09-20 14:36

#9

帖子 moxien » 2008-07-03 22:16

重启后可以了。感谢楼主。
新手中的菜鸟
帖子: 4
注册时间: 2008-10-19 17:33

Re: [问题]apt无法正常使用[已解决][附解决方法]

#10

帖子 新手中的菜鸟 » 2008-11-20 21:43

:em05 狂谢呀,我也一样,特别对一外菜鸟来说更难了
头像
A2128
帖子: 59
注册时间: 2008-12-11 8:54
来自: 北京
联系:

Re: [问题]apt无法正常使用[已解决][附解决方法]

#11

帖子 A2128 » 2008-12-25 23:39

今天碰到了几乎同样的问题,搜索论坛的时候发现了这个帖子;
其实我也使用类似的方法在公司局域网内使用proxy,但是今天碰到的问题用这个帖子的方法却没有解决,所以特此在这个帖子后面做个补充;希望那些能够认真看帖子的人能够看到。

我的现象和monnand的几乎是一样的,每次运行apt-get update,apt都试图去连接一个代理服务器地址,这个地址实际上是我在公司网络里面用的。
于是,检查了env, export, .bashrc, /etc/environment,把发现的http_proxy都删除掉了,重启ubuntu还是不行;而firefox是可以上网的,pidgin,飞信都可以上,那是什么原因呢?

感觉上,只有可能是apt的配置了;因为知道sources.list在/etc/apt的目录里面,于是到里面找找看,发现了一个名字叫作apt.conf的文件。
more apt.conf 得到的结果是Acquire::http::proxy "http://172.30.246.8:8080/"; 原来问题出在这里。

在搜索,找到了这篇文章:http://wiki.ubuntu.org.cn/UbuntuHelp:AptGetHowto

那么下面所要做的就是:
cp apt.conf apt.conf.proxy
sudo nano apt.conf
然后删除那一行就可以了
一个拥有Ubuntu精神的人心胸开阔、乐于助人、善待他人、不因别人的优秀而感受到威胁。这是因为他们有一种恰当的自信,这种自信源于对于每个人都属于一个更大的整体的理解,他们在别人承受屈辱、贬低、痛苦和压抑时感同身受。
--Desmond Tutu
头像
hualuo
帖子: 14
注册时间: 2008-10-25 10:21
联系:

Re: [问题]apt无法正常使用[已解决][附解决方法]

#12

帖子 hualuo » 2010-06-04 2:00

jiuluojiaoy
我相信我可以。
回复