Software & AppsOperating SystemLinux

How To Fix “sudo add-apt-repository” Hanging Issue in Ubuntu 18.04?

Ubuntu 2

In Ubuntu, the sudo add-apt-repository command is a convenient way to add new repositories to your system. However, sometimes you may encounter an issue where the command hangs and does not return. This can be a frustrating problem, but don’t worry, there are several solutions you can try.

Understanding the Issue

Before we dive into the solutions, let’s first understand the problem. The sudo add-apt-repository command is a part of the software-properties-common package. It is used to add Personal Package Archives (PPAs) to your system’s software sources. A PPA is a repository of software that is not included in the official Ubuntu repositories.

The command hangs when it is unable to connect to the PPA server. This could be due to several reasons such as network connectivity issues, issues with the PPA server, or running the command behind a proxy.

Solution 1: Configure the Proxy for APT

If you are running the command behind a proxy, this could be the cause of the connectivity issues. You can configure the proxy settings for APT to resolve this issue.

Open the APT configuration file using the command:

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

In the opened file, add the following lines:

Acquire::http::Proxy "http://your-proxy-server:port/";
Acquire::https::Proxy "http://your-proxy-server:port/";

Replace your-proxy-server:port with your actual proxy server address and port. Save the file and exit. This should allow APT to work behind the proxy.

Solution 2: Check the PPA and Repository

Sometimes, the issue could be with the specific PPA you are trying to add. Ensure that the PPA is valid and accessible. You can try visiting the PPA URL in your browser to see if it loads properly. If the PPA is not accessible, you may need to wait until it is back online or find an alternative repository.

Solution 3: Use Alternative Methods

If the add-apt-repository command continues to hang, you can try alternative methods to add the repository.

Method 1: Manually Edit sources.list

You can manually edit the /etc/apt/sources.list file and add the repository details. Open the file using the command:

sudo nano /etc/apt/sources.list

Then, add the repository details at the end of the file. The details should be in the following format:

deb bionic main
deb-src bionic main

Replace PPA_NAME with the name of the PPA you are trying to add.

Method 2: Use software-properties-common

The software-properties-common package provides a graphical interface for managing repositories. You can install it using the command:

sudo apt-get install software-properties-common

After installing, you can use the software-properties-gtk command to add the repository.

Solution 4: Restart the Network Manager

In some cases, restarting the network manager can help resolve connectivity issues. You can do this by running the following command:

sudo service network-manager restart

After restarting the network manager, try running the add-apt-repository command again.


The sudo add-apt-repository hanging issue in Ubuntu 18.04 can be caused by various factors, and the solutions above may not work in all cases. However, they are a good starting point for troubleshooting the issue. If none of the solutions work, you may need to seek further assistance or consider alternative methods for installing the software you need.

How do I check if I am behind a proxy?

You can check if you are behind a proxy by running the command env | grep proxy in the terminal. This will display any proxy settings that are currently set.

How do I find the PPA URL?

To find the PPA URL, you can search for the desired PPA on the Launchpad website. Once you find the PPA, click on it to open the PPA page. The URL in your browser’s address bar will be the PPA URL.

How can I manually edit the sources.list file?

To manually edit the sources.list file, open the terminal and run the command sudo nano /etc/apt/sources.list. This will open the file in the nano text editor. Make the necessary changes, save the file by pressing Ctrl + O, and exit nano by pressing Ctrl + X.

How do I install software-properties-common?

You can install software-properties-common by running the command sudo apt-get install software-properties-common in the terminal. This will install the package and its dependencies.

How can I restart the network manager?

To restart the network manager, run the command sudo service network-manager restart in the terminal. This will restart the network manager and may resolve connectivity issues.

Leave a Comment

Your email address will not be published. Required fields are marked *