15

I am very new to Ubuntu. I am behind a secure proxy too. when I try to run sudo apt-get update I get the following error.

blah@blah-hp-15-notebook-pc:~$ sudo apt-get update
Err http://security.ubuntu.com vivid-security InRelease
Err http://in.archive.ubuntu.com vivid InRelease
Err http://security.ubuntu.com vivid-security Release.gpg
Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1360:8c01::18). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::18 80]
Err http://in.archive.ubuntu.com vivid-updates InRelease         
Err http://in.archive.ubuntu.com vivid-backports InRelease
Err http://in.archive.ubuntu.com vivid Release.gpg                  
Cannot initiate the connection to in.archive.ubuntu.com:80 (2001:67c:1360:8c01::18). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::18 80]
Err http://in.archive.ubuntu.com vivid-updates Release.gpg
Cannot initiate the connection to in.archive.ubuntu.com:80 (2001:67c:1360:8c01::18). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::18 80] 
Err http://in.archive.ubuntu.com vivid-backports Release.gpg
Cannot initiate the connection to in.archive.ubuntu.com:80 (2001:67c:1360:8c01::18). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::18 80] 
Reading package lists... Done
W: Failed to fetch http://in.archive.ubuntu.com/ubuntu/dists/vivid/InRelease
W: Failed to fetch http://in.archive.ubuntu.com/ubuntu/dists/vivid-updates/InRelease   
W: Failed to fetch http://in.archive.ubuntu.com/ubuntu/dists/vivid-backports/InRelease
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/vivid-security/InRelease
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/vivid-security/Release.gpg  Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1360:8c01::18). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::18 80]
W: Failed to fetch http://in.archive.ubuntu.com/ubuntu/dists/vivid/Release.gpg  Cannot initiate the connection to in.archive.ubuntu.com:80 (2001:67c:1360:8c01::18). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::18 80]
W: Failed to fetch http://in.archive.ubuntu.com/ubuntu/dists/vivid-updates/Release.gpg  Cannot initiate the connection to in.archive.ubuntu.com:80 (2001:67c:1360:8c01::18). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::18 80]
W: Failed to fetch http://in.archive.ubuntu.com/ubuntu/dists/vivid-backports/Release.gpg  Cannot initiate the connection to in.archive.ubuntu.com:80 (2001:67c:1360:8c01::18). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::18 80]
W: Some index files failed to download. They have been ignored, or old ones used instead.

Does anyone know how to start fixing it?

6
  • 7
    apt is trying IPv6 addresses which are not reachable..try forcing IPv4 by sudo apt-get -o Acquire::ForceIPv4=true update
    – heemayl
    Nov 2, 2015 at 2:51
  • Change the server to main
    – Raphael
    Nov 2, 2015 at 3:28
  • @heemayl i made the change. I think i need to make more changes!
    – curio17
    Nov 2, 2015 at 3:29
  • 1
    Does this answer your question? Configure proxy for APT?
    – Melebius
    Feb 3, 2020 at 13:06
  • 1
    Sometimes, this CAN be an internet provider thing - try a different wifi, or maybe a mobile data hotspot :)
    – jave.web
    Jul 27, 2020 at 22:38

7 Answers 7

20

I also face the same problem. To overcome it, you need to change the server to the main server.

Just go to Software & Updates and change the server to the main server next to Download from.

Software & Updates dialog - Download from: main server

First time after Ubuntu installation you may not be able to find Main server option. Then follow this - Download from -> other... -> Select Best Server -> Choose Server. This will select the optimum server and might take some time. Afterwards sudo apt-get update && sudo apt-get upgrade. If you go and check Download from now onwards you will find Main server in the available list.

2
  • Any idea how I would choose "Main Server" when using command line? "$ sudo apt-get update && sudo apt-get upgrade" Aug 5, 2021 at 13:03
  • Thanks a lot ! This solution worked perfectly 👍
    – programmer
    May 29, 2022 at 7:26
2

You can add proxy settings in /etc/apt/apt.conf file;

echo "Acquire::http::proxy \"http://<proxy_server>:<port>/\";" >> /etc/apt/apt.conf
echo "Acquire::https::proxy \"https://<proxy_server>:<port>/\";" >> /etc/apt/apt.conf

After, you can try;

sudo apt-get update
1

If after connecting to a VPN on Windows, bash loses network connectivity, try this workaround from within bash. This workaround will allow you to manually override the DNS resolution through /etc/resolv.conf.

  1. Take a note of the DNS server of the VPN from doing ipconfig.exe /all
  2. Make a copy of the existing resolv.conf sudo cp /etc/resolv.conf /etc/resolv.conf.new
  3. Unlink the current resolv.conf sudo unlink /etc/resolv.conf
  4. sudo mv /etc/resolv.conf.new /etc/resolv.conf
  5. Open /etc/resolv.conf and

a. Delete the first line from the file, which says "# This file was automatically generated by WSL. To stop automatic generation of this file, remove this line.". b. Add the DNS entry from (1) above as the very first entry in the list of DNS servers. c. Close the file.

Once you have disconnected the VPN, you will have to revert the changes to /etc/resolv.conf. To do this, do:

  1. cd /etc
  2. sudo mv resolv.conf resolv.conf.new
  3. sudo ln -s ../run/resolvconf/resolv.conf resolv.conf
1

It's probably your internet connection. I had this exact problem, then connected to a different wifi and the problem was gone

1
  • I had the same issue and it was the internet connection similar to what @Bemigho have mentioned
    – Ghada
    Aug 9, 2022 at 22:00
1

I had this problem too. For me it was a network related prolem, missing default gateway configuration. Added the default gateway to resolve this issue

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center. Sep 6, 2022 at 20:24
0

The issue is with the proxy setup for apt. Try this through the shell if you do not have UI access.

  • Create a new configuration file named proxy.conf

    sudo touch /etc/apt/apt.conf.d/proxy.conf

  • Open the proxy.conf file in a text editor.

    sudo vi /etc/apt/apt.conf.d/proxy.conf

  • Add the following line to set your HTTP and HTTPS proxies.

    Acquire::http::Proxy "http://user:[email protected]:port/";

    Acquire::https::Proxy "http://user:[email protected]:port/";

Now try sudo apt update

0

thanks to Okmer this worked for me, being behind a proxy:

echo "Acquire::http::proxy "http://<proxy_server>:/";" >> /etc/apt/apt.conf echo "Acquire::https::proxy "https://<proxy_server>:/";" >> /etc/apt/apt.conf

Need to understand why it was working without it before and after adding a PPA repository, it just being blocked. I'll post the next troubleshooting to help similar cases.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .