Home FAQ How To Force APT Package Manager To Use IPv4 In Ubuntu

How To Force APT Package Manager To Use IPv4 In Ubuntu

By sk
Published: Last Updated on 6.5K views

APT, short or Advanced Package Tool, is the default package manager for Debian-based systems. Using APT, we can install, update, upgrade and remove applications from the system. Lately, I have been facing a strange error.  Whenever I try update my Ubuntu 16.04 box, I get this error - "0% [Connecting to in.archive.ubuntu.com (2001:67c:1560:8001::14)]" and the update process gets stuck for a long time. My Internet connection is working well and I can able to ping all websites including Ubuntu official site. After a couple Google searches, I realized that sometimes the Ubuntu mirrors are not reachable over IPv6. This problem is solved after I force APT package manager to use IPv4 in place of IPv6 to access Ubuntu mirrors while updating the system. If you ever encountered with this error, you can solve it as described below.

Force APT Package Manager To Use IPv4 In Ubuntu 16.04

To force APT to use IPv4 in place of IPv6 while updating and upgrading your Ubuntu 16.04 LTS systems, simply use the following commands:

$ sudo apt-get -o Acquire::ForceIPv4=true update
$ sudo apt-get -o Acquire::ForceIPv4=true upgrade

Voila! This time update process ran and completed quickly.

You can also make this persistent for all apt-get transactions in the future by adding the following line in /etc/apt/apt.conf.d/99force-ipv4 file using command:

$ echo 'Acquire::ForceIPv4 "true";' | sudo tee /etc/apt/apt.conf.d/99force-ipv4

Disclaimer:

I don't know if anyone is having this issue lately, but I kept getting this error today at least four to five times in my Ubuntu 16.04 LTS virtual machine and I solved it as described above. I am not sure that it is the recommended solution. Go through Ubuntu forums and make sure this method is legitimate. Since mine is just a VM which I use it only for testing and learning purposes, I don't mind about the authenticity of this method. Use it on your own risk.

Source:

Thanks for stopping by!

Help us to help you:

Have a Good day!!

You May Also Like

2 comments

Anony October 13, 2018 - 1:56 am

Thanks a lot for this tip bro.
It nearly drove me crazy on my virtual VPS.

Reply
sk October 13, 2018 - 11:44 am

Glad it helped you.

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More