In this article, we cover how to fix failed to fetch or could not resolve repository error. Repositories help us install programs in Ubuntu. When it comes to the standard Ubuntu repository, the packages available through them are tested and tailor-made for each specific version of Ubuntu.
Not only that, packages available through standard Ubuntu repositories are far more secure. Furthermore, we can also install packages through third-party repositories. But, that should come from a trusted source.
At times, a repository may not be available for various reasons. They could no longer be maintained.
Note: Following operations require Administrative rights. If you don’t have the required rights, we advise you to contact your System Administrator for assistance.
[Fixed]: Failed to fetch or Could not resolve repository error
We update repositories to ensure that we get the latest version of packages. But, what if the repository itself isn’t available? In that case, when we update the repository through the following command:
sudo apt update
It results in Failed to fetch or could not resolve repository error. Though the problem could be associated with either one or two repositories that affect the entire package management. Clearly, we have to remove the failed repository data from the system configuration.
We can find repositories in the file:
or, in the directory (as *.list file):
Look for the entry that troubles us. And, put a # in front of that to disable the repository. For instance, if the original repository was:
deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main
And, if we wish to disable it then put a #:
# deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main
That disables it. Now, run the following command again:
sudo apt update
It is worth mentioning here that, though we have disabled the repository. The packages that we have installed through the disabled repository can no longer be updated. And, that poses a security risk. So, it is better to disable it temporarily. Till we update or install a new package. Once it’s done, try to identify the cause that led to failed to fetch repository error.
It’s a different thing if the entire repository isn’t available anymore. But, if it is then try to enable it back by removing the # we placed earlier.
In conclusion, it is better to disable the repository that is causing the issue temporarily while we investigate the underlying cause. And, should take the necessary steps depending on what we have got.