Ubuntu – Apt-get install behind proxy – Failed to fetch


This is yet another question regarding the error message E: Failed to fetch ... (example in Note 2 below).
What makes this question different (I guess) from the others I have seen is the following.

I am running Ubuntu 18.04LTS, behind a proxy.
I had a lot of packages with available updates (more than 200, I guess).

    I could update many of the packages with no problem, and I ended up with 48 that I cannot install.

All of the packages not installed belong to bionic-updates/universe or bionic-updates/main.
And most are related to java, jdk, linux, systemd.
The complete list is in Note 1 below.
But there are packages from bionic-updates/universe and bionic-updates/main that I can install (I just installed qemu and bsdutils).

How is it possible that some of the packages can be installed and some cannot?

What is a possible solution (other than connecting the PC without a proxy)?


  1. Complete list of packages not installed

    ant ant-optional apport apport-gtk fwupd fwupdate fwupdate-signed gettext gettext-base jarwrapper junit4 libasm-java libcommons-collections3-java libcommons-compress-java libcommons-httpclient-java libdb5.3 libdb5.3-java libdb5.3-java-jni libecj-java libequinox-osgi-java libhsqldb1.8.0-java libjetty9-java libnss-systemd libobjenesis-java libpam-systemd libservlet3.1-java libsystemd0 libtomcat8-java linux-generic linux-headers-generic linux-image-generic openjdk-11-jdk openjdk-11-jdk-headless openjdk-11-jre openjdk-11-jre-headless openjdk-8-jdk openjdk-8-jdk-headless openjdk-8-jre openjdk-8-jre-headless python-pip-whl python3-pip snapd systemd

This was obtained with

$ sudo apt list --upgradable 2> /dev/null | sed 's/\/.*//' | tail +2 | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/ /g'

To find which repo each one belonged, I used (printf "%30s"... helps visualizing in columns)

$ for p in $(sudo apt list --upgradable 2> /dev/null | sed 's/\/.*//' | tail +2 | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/ /g') ; do printf "%30s" $p ; apt policy $p 2> /dev/null | tail +6 | head -1 ; done

This generates output like

                       ant        500 http://us.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages
  1. Sample error
    $ sudo apt-get install apport
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    The following packages will be upgraded:
    1 upgraded, 0 newly installed, 0 to remove and 46 not upgraded.
    Need to get 125 kB of archives.
    After this operation, 20,5 kB of additional disk space will be used.
    Ign:1 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 apport all 2.20.9-0ubuntu7.17
    Err:1 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 apport all 2.20.9-0ubuntu7.17
      403  URLBlockDownload [IP: xxx.xxx.xxx3.xxx 80]
    E: Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/main/a/apport/apport_2.20.9-0ubuntu7.17_all.deb  403  URLBlockDownload [IP: 80]
    E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
  1. EDIT: output "requested" in this answer is here.
    $ find /etc/apt/ -name "*.list" -exec grep -iq http {} \; -exec egrep -v '^#|^$' {} \; | uniq 
    deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main
    deb http://us.archive.ubuntu.com/ubuntu/ bionic main restricted
    deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
    deb http://us.archive.ubuntu.com/ubuntu/ bionic universe
    deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates universe
    deb http://us.archive.ubuntu.com/ubuntu/ bionic multiverse
    deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates multiverse
    deb http://us.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
    deb http://security.ubuntu.com/ubuntu bionic-security main restricted
    deb http://security.ubuntu.com/ubuntu bionic-security universe
    deb http://security.ubuntu.com/ubuntu bionic-security multiverse
    deb https://apt.kitware.com/ubuntu/ bionic main

Best Answer

  • It looks like enterprise firewall is blocking certain urls of apt, that's why you are not able to download packages via apt. You need to get all URLs white listed in firewall mentioned in source list. You need to have admin access of firewall or kindly contact network administrator.

    As Alternative option, try to connect system directly with another internet source like USB Dongle or Mobile.