Apt-get 403 Forbidden, but accessible in the browser

Solution 1:

So it turns out this is an issue with squid-deb-proxy. Unfortunately it doesn't add PPAs and other repositories and just fails with an rather unexpected 403 error.

You can fix this by adding the repositories to the config file:

/etc/squid-deb-proxy/mirror-dstdomain.acl

# launchpad personal package archives (disabled by default) 
ppa.launchpad.net                                           
private-ppa.launchpad.net                                   

Of course, uninstalling squid-deb-proxy also works around the issue:

apt-get remove squid-deb-proxy

Solution 2:

Are you using proxy?

I have often experience this error, even when using main server.I noticed that this happens when apt-get process breaks for some reason. For instance when running apt-get update downloading of some file coudn't be completed. You will there after get 403 error for that particular file.

I learned that these partially downloaded files (I am not sure if they are exactly the files) during apt-get update are stored in /var/lib/apt/lists/partial/

So I did sudo rm -r /var/lib/apt/lists/partial/*(deleted all files in the directory)

After this I din't get the 403 error.

If you are getting the error when running apt-get install or apt-get upgrade or apt-get dist-upgrade

try sudo rm -r /var/cache/apt/archives/partial/*