使用 apt-get update E: Failed to fetch http://...... File has unexpected size

use apt-get update E: Failed to fetch http://...... File has unexpected size

E: Failed to fetch http://mirrors.kali.com/kali/dists/kali-rolling/main/binary-i386/Packages.gz  File has unexpected size (15320738 != 15317336). Mirror sync in progress? [IP: 111.11.111.111 80]
   Hashes of expected file:
    - Filesize:15317336 [weak]
    - SHA256:c4762e83455984f8d3fb54f6f42836808b8c891ba117661b61240bc5774d2e02
    - SHA1:fdebd56e7541e6f88d7910988ef694d3c409e21d [weak]
    - MD5Sum:51400b889af8677132f31d56f266bf22 [weak]
   Release file created at: Fri, 06 Oct 2017 06:55:45 +0000
E: Some index files failed to download. They have been ignored, or old ones used instead.

这是错误page.How来处理这个问题?

我已经解决了。您似乎在 /etc/apt/sources.list 中添加了不止一个源条目。我猜不止一个条目会使 apt 命令混淆,可能从一个来源获取 header 然后从另一个来源获取包,并且包大小可能不等于 header 中定义的包大小。编辑文件,只留下一个对我有用的源条目。希望这有帮助

检查防火墙是否阻止了它。对我来说,是防火墙将数据包检测为恶意数据包。

首先打开文件 /etc/apt/sources.list,然后删除所有行并添加这些行

deb http://repo.kali.org/kali kali-rolling main non-free contrib
deb-src http://repo.kali.org/kali kali-rolling main non-free contrib

保存并再次执行

sudo apt-get update

我遇到了同样的问题。这是我的解决方案,它适用于 VirtualBox 中的 Kali。

请将您的 /etc/apt/sources.list 更新为

deb https://http.kali.org/kali kali-rolling main non-free contrib

例子

root@kali:~# cat /etc/apt/sources.list
deb https://http.kali.org/kali kali-rolling main non-free contrib
# deb-src https://http.kali.org/kali kali-rolling main non-free contrib
root@kali:~#

让我们更新它...

root@kali:~# apt update
Hit:1 https://archive-3.kali.org/kali kali-rolling InRelease
Reading package lists... Done
root@kali:~#

希望这对您有所帮助。