APT update fails: writing more data than expected [duplicate]

when trying to update package listings via apt update or apt-get update I receive the following error:

E: Failed to fetch http://lt.archive.ubuntu.com/ubuntu/dists/xenial/universe/dep11/Components-amd64.yml.gz  Hash Sum mismatch
E: Failed to fetch http://lt.archive.ubuntu.com/ubuntu/dists/xenial/universe/dep11/icons-64x64.tar  Writing more data than expected (7468511 > 7467723) [IP: 193.219.61.87 80]

Is this somehow related to localised package distributor or is me all along? I am running beta2 release, that I've successfully installed and updated (without any error prompts) yesterday. Previously I used a 14.04 derivative which also did not bring up any errors. What can be the reason for this error?

EDIT: to duplicate markers, the topic name tackles a different problem rather than the hash sum problem, which is being referenced.


Solution 1:

Add a parameter that adds a 'no-cache' header to the http/https requests. It asks the apt server to provide un-cached files. This can be useful if there are any kind of (broken) caching mechanism between your machine and apt mirror/server. (Such as proxy, transparent caching by ISP etc)

sudo apt -o Acquire::https::No-Cache=True -o Acquire::http::No-Cache=True update

just run this command in your terminal and it should work just fine

Solution 2:

I think you've been accessing the local repo mirror while being updated. Wait some time (usually 1 hour is enough) before trying again. This can happen to all live releases, not just 16.04 (which is not officially out yet, as commented by someone else).

As an option, you could edit /etc/apt/sources.list to expunge the "lt" prefix with your favorite editor or use

sudo sed -i 's/http:\/\/lt\./http:\/\//g' /etc/apt/sources.list

This will make you access the main repositories at the cost of a slower access.

Of course, you can replace lt with your very own ISO 3166-1 alpha-2 country code.