Cannot use apt on ubuntu 22.04.2, throws error "Cannot resolve « proxy-web-or-IP-address:port-number»"

While trying to install gcc I started to get an error using sudo apt.
Now apt doesn’t seem to work for anything. Most notably, sudo apt update throws the following:

Ign:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Ign:2 http://security.ubuntu.com/ubuntu jammy-security InRelease
Ign:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Ign:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
Ign:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Ign:2 http://security.ubuntu.com/ubuntu jammy-security InRelease
Ign:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Ign:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
Ign:2 http://security.ubuntu.com/ubuntu jammy-security InRelease
Ign:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Ign:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Ign:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease

Err:2 http://security.ubuntu.com/ubuntu jammy-security InRelease
 Failed to resolve « proxy-web-or-IP-address:port-number»
Err:1 http://archive.ubuntu.com/ubuntu jammy InRelease
 Failed to resolve « proxy-web-or-IP-address:port-number»
Err:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Failed to resolve « proxy-web-or-IP-address:port-number»
Err:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
Failed to resolve « proxy-web-or-IP-address:port-number»
Reading package list... Done
Creating dependency tree... Done
Reading the status information... Done
9 packages can be upgraded. Run "apt list --upgradable" to view them.
W: Failed to get http://archive.ubuntu.com/ubuntu/dists/jammy/InRelease Could not resolve « proxy-web-or-IP-address:port-number»
W: Failed to get http://archive.ubuntu.com/ubuntu/dists/jammy-updates/InRelease Could not resolve « proxy-web-or-IP-address:port-number»
W: Failed to get http://archive.ubuntu.com/ubuntu/dists/jammy-backports/InRelease Could not resolve « proxy-web-or-IP-address:port-number»
W: Failed to get http://security.ubuntu.com/ubuntu/dists/jammy-security/InRelease Could not resolve « proxy-web-or-IP-address:port-number»
W: Some index files could not be downloaded, omitted, or old ones were used instead.

And most other commands about installing or upgrading throw a similar error.

I don’t have a proxy activated. Also, I tried using the "Autoupdate" Software app, but it doesn’t work neither. I tried deleting the sources.list document and replacing it by other with:

deb http://archive.ubuntu.com/ubuntu/ jammy main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse

Other detail is that I was previously trying to solve a problem of performance that makes the laptop suddenly freeze.
And that I’m running Ubuntu 22.04.2 LTS on and Acer Swift 3.

Edit: Thanks everyone. Specially Vidarlo, I found the solution to my problem. Commenting out the proxy-realted lines in apt.conf or creating a 95proxy.conf file with proxy set on off seems works fine so far.

Asked By: BlackNevada

||

It seems like you’re getting an error when trying to use apt on your Ubuntu 22.04.2 machine. The error is "Cannot resolve « proxy-web-or-IP-address:port-number»", which means that apt is unable to resolve the hostname or IP address of your proxy server.

You mentioned that you don’t have a proxy activated, so this is probably a false positive. However, there are a few things you can try to fix the issue:

  1. Check your proxy settings. Make sure that you don’t have a proxy configured in your system settings or in your /etc/apt/apt.conf file.
  2. Delete the /etc/apt/apt.conf.d/proxy file. This file is used to configure proxy settings for apt, and it may be causing the issue.
  3. Try running sudo apt update with the --force-confold option. This will force apt to ignore the proxy settings and use the default configuration.

If you’re still having problems, you can try asking for help on a forum or mailing list. There are a lot of knowledgeable people out there who can help you troubleshoot this issue.

Here are some additional tips that might help you fix the problem:

  • Make sure that your network connection is working properly.
  • Try restarting your computer.
  • Update your system’s packages.
Answered By: fku

It seems like you’re facing some issues with the apt package manager on your Ubuntu 22.04.2 system. The error message suggests a problem with resolving the proxy web address or IP. Although you mentioned that you don’t have a proxy activated, it could still be causing conflicts. Let’s try a few troubleshooting steps to resolve this.

Firstly, it’s worth checking your network settings to ensure that no proxy configuration is active. Open the "Settings" app, navigate to the "Network" section, and verify that the proxy settings are disabled or set to "None."

If you’re certain that the proxy settings are disabled, we can proceed with further troubleshooting steps. Open a terminal and enter the following commands:

  1. Clear the apt cache:
sudo apt clean
  1. Reset the proxy environment variables:
unset http_proxy
unset https_proxy
  1. Update the apt configuration file:
sudo nano /etc/apt/apt.conf

In the text editor, check if there are any proxy-related settings present. If you find any lines referring to a proxy, either remove or comment them out by adding a "#" at the beginning of each line. Save the file and exit the text editor.

  1. Reconfigure the package sources:
sudo dpkg --configure -a
sudo apt update

These commands will reconfigure the package manager and update the package sources. Hopefully, this will resolve the issue you’re experiencing.

If you’re still facing problems, there could be a DNS issue. You can try changing your DNS servers to a reliable option such as Google DNS or Cloudflare DNS. Here’s how:

  1. Open the network settings again.
  2. Go to the "Network" section and select your active network connection.
  3. Click on the gear icon to edit the connection settings.
  4. In the IPv4 or IPv6 tab (depending on your network configuration), change the DNS server address to either "8.8.8.8, 8.8.4.4" (Google DNS) or "1.1.1.1, 1.0.0.1" (Cloudflare DNS).
  5. Save the changes and restart your network connection.

After changing the DNS servers, try running sudo apt update again to see if the issue is resolved.

Answered By: mmp

Firstly, open up a terminal and use the following command to check if there are any environment variables set up for a proxy. Your system might be confused and think it’s behind a proxy:

env | grep -i proxy

If that command throws out any results, we’ve got a bingo. Now you need to remove those environment variables. You can do so by opening up your bashrc file in a text editor (like nano or vim) and commenting out or removing any lines that have to do with a proxy:

nano ~/.bashrc

After you’ve done this, save the file and exit, and then either restart your terminal session or use the following command to apply the changes:

source ~/.bashrc

Now, let’s have another look at the apt settings. Open up the apt configuration file and check if there’s anything in there about a proxy:

sudo nano /etc/apt/apt.conf

If you find any lines that refer to a proxy, go ahead and comment them out (you can do this by adding a ‘#’ at the start of the line) or remove ’em. After you’re done, save that file and close it.

Finally, update your system and check if everything’s hunky-dory:

sudo apt update && sudo apt upgrade

If the error still persists, you might need to double-check your network settings or even try a different DNS server, like Google DNS (8.8.8.8 or 8.8.4.4), to see if it’s a DNS resolution issue.

Answered By: hmp
Categories: Answers Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.