Solve Error: Cannot initiate the connection to

If you are facing a problem “Cannot initiate the connection to” error while performing the system update or installing some application then here is the solution.

Linux can make new users a little annoying when some warning or error appears, however, resolving errors is the best way to get one step closer to becoming an experienced Linux user. However, coming to the point, i.e how to solve this error.

Such an error appears when the default repository servers are not reachable by our system. In such a case, we can switch to the main servers of Ubuntu to download and install the required packages on our system.

Here we learn how to do that, follow the given steps.

#Using GUI:

If you are using a Graphical user interfaced Ubuntu Desktop system, then switching to the main server is quite simple.

1. Open Software & Updates

Go to Application launcher and there search for “Software & Updates” as its icon appears, click to open it.

Software and Updater on Ubuntu 22.04


2. Change Server

There under the “Ubuntu Software” tab, go to Download from the drop-down box and select “Main Server“. After that, the system will ask for your user password to save the changes.

Select Main Server of Ubuntu


3. Regenerate APT cache

Give that and click on the Close button.  The system will regenerate the system repository index APT cache. Now, you can easily download the updates and other software applications using the package manager.

Set Ubuntu Software Download source


#Using CMD

4. Change Mirror Ubuntu servers using terminal

If you are using the Command line interface of Ubuntu in India and want to use the terminal for changing the mirror server URL to main. Here is the command to follow:

sudo sed -i 's|http://in.|http://|g' /etc/apt/sources.list

The above command will remove the ‘in‘ from the source URL list to convert them Main server URL. In the same way, if you are using US mirrors then replace the ‘in‘ in the command with ‘us‘.

For example:

sudo sed -i ‘s|http://us.|http://|g’ /etc/apt/sources.list

Similarly, you can replace ‘us‘ with any other mirror you want.

Command explanation:

sed – stream editor for filtering and transforming text.

The -i argument is to edit a file in place.

Then ‘s|regexp|replacement|g’s specifying the search and replace command.

The g at the end is the argument to “globally” search.

hence, the command will simply search http://in and then replace it with http:// in the file /etc/apt/sources.list.


5. Clean and Update

Once you have changed the Mirror URLs to Main Server or the one you want, clear the APT cache and update it.

sudo apt clean
sudo apt update


Other Articles:

Upgrade Ubuntu 20.04 To 22.04 LTS Jammy using Command 
How to use Google Cloud Calculator 
How to install Miniconda on Ubuntu
Install Supertuxkart Game on Ubuntu 22.04



Leave a Comment

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