Score:0

Do I need to setup my own Proxy Address/Server in Ubuntu Server 22.04 to use "sudo apt update"?

so flag

Ubuntu newbie here.

When using the "sudo apt update" command, I receive the following errors below. When searching around, it seems like the resolution is I need to setup a proxy server? (https://linuxiac.com/how-to-use-apt-with-proxy/)

When I setup my Ubuntu Server, I didn't input any info for "proxy server".

This Ubuntu Server is being setup for at home use / linux training. So I didn't use Ubuntu Desktop. Should I have in this case?

Errors I get when using "sudo apt update"

Ign:1 http://us.archive.ubuntu.com/ubuntu jammy InRelease
Ign:2 http://us.archive.ubuntu.com/ubuntu jammy-updates InRelease
Ign:3 http://us.archive.ubuntu.com/ubuntu jammy-backports InRelease
Ign:4 http://us.archive.ubuntu.com/ubuntu jammy-security InRelease
Ign:1 http://us.archive.ubuntu.com/ubuntu jammy InRelease
Ign:2 http://us.archive.ubuntu.com/ubuntu jammy-updates InRelease
Ign:3 http://us.archive.ubuntu.com/ubuntu jammy-backports InRelease
Ign:4 http://us.archive.ubuntu.com/ubuntu jammy-security InRelease
Ign:1 http://us.archive.ubuntu.com/ubuntu jammy InRelease
Ign:2 http://us.archive.ubuntu.com/ubuntu jammy-updates InRelease
Ign:3 http://us.archive.ubuntu.com/ubuntu jammy-backports InRelease
Ign:4 http://us.archive.ubuntu.com/ubuntu jammy-security InRelease
Err:1 http://us.archive.ubuntu.com/ubuntu jammy InRelease
  Could not connect to 127.0.0.1:8080 (127.0.0.1). - connect (111: Connection reused)
Err:2 http://us.archive.ubuntu.com/ubuntu jammy-updates InRelease
  Unable to connect to 127.0.0.1:8080:
Err:3 http://us.archive.ubuntu.com/ubuntu jammy-backports InRelease
  Unable to connect to 127.0.0.1:8080:
Err:4 http://us.archive.ubuntu.com/ubuntu jammy-security InRelease
  Unable to connect to 127.0.0.1:8080:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/jammy/InRelease  Cold not connect to 127.0.0.1:8080 (127.0.0.1). - connect (111: Connection refused
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/jammy-updates/InRelase  Unable to connect to 127.0.0.1:8080:
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/jammy-backports/InRlease  Unable to connect to 127.0.0.1:8080:
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/jammy-security/InReease  Unable to connect to 127.0.0.1:8080:
W: Some index files failed to download. They have been ignored, or old ones usedinstead.

My setup: Ubuntu Server 22.04 via Virtual Box

  • I setup my Ubuntu Server with a static ip as I will be ssh-ing into the Ubuntu Server from MobaXterm. Which requires me to use Adapter 1: NAT and Adapter 2: Host-only Adapter in Virtual Box to be able to configure Static IP.

enp0s8 is my static ip I setup

enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.2.15  netmask 255.255.255.0  broadcast 10.0.2.255
        inet6 fe80::a00:27ff:fea7:4074  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:a7:40:74  txqueuelen 1000  (Ethernet)
        RX packets 154  bytes 20644 (20.6 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 193  bytes 18082 (18.0 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.56.10  netmask 255.255.255.0  broadcast 192.168.56.255
        inet6 fe80::a00:27ff:fed2:c892  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:d2:c8:92  txqueuelen 1000  (Ethernet)
        RX packets 3567  bytes 286366 (286.3 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3522  bytes 373812 (373.8 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 532  bytes 47862 (47.8 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 532  bytes 47862 (47.8 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    ```
cn flag
Just to be sure, you _did_ set up a proxy server at `127.0.0.1:8080`? Telling `apt` about a proxy, like in the tutorial you linked, doesn't create the proxy server itself. It basically just tells `apt`, "when you're downloading something, don't go to the internet directly, but try to reach anything through the following intermediary". It looks like that intermediary isn't there or isn't taking any requests for some reason.
01Tech avatar
so flag
Nope, I haven't setup anything. I didn't input any info in the proxy section when setting up the Ubuntu Server. That's why I'm confused. Do I need to setup a proxy server?
cn flag
To have `apt` (or anything, for that matter) use a proxy server, you need to have a proxy server, correct ;) Whether you set up a proxy server yourself or use one provided to you (by your IT department, your ISP or other), you need to have one. Otherwise, it's a bit like you say "drive _this_ car to the grocery store" without having a car ;) Maybe you want to read up on what a proxy server is and does. Because running a proxy on `localhost`, the same machine the client is one, doesn't seem that useful to me ;)
Terrance avatar
id flag
Did you look in Settings -> Software & Updates to see if you have any local (Other Software) 3rd party repository enabled that could be causing this?
01Tech avatar
so flag
I'm only using it for homesetup / linux training. Nothing extraordinary. @HenningKockerbeck To conclude, your saying I need to setup a proxy server in Ubuntu like below? https://citizix.com/how-to-install-and-configure-squid-proxy-on-ubuntu-22-04/
01Tech avatar
so flag
@Terrance I'm on Ubuntu Server, I don't have the GUI :(
Terrance avatar
id flag
Sorry, use `grep "127.0.0.1" /etc/apt/sources.list.d/*.list` to see if any of those have that listed.
01Tech avatar
so flag
@Terrance When running the command you suggested, this is what comes back: "grep: /etc/apt/sources.list.d/*.list~: No such file or directory"
Terrance avatar
id flag
Or try `grep -iR "127.0.0.1" /etc/apt/*` You might though need to fix your question and title because you make it sound like you want a proxy setup, but then your question shows that you are erroring out with a proxy that you don't want.
01Tech avatar
so flag
@Terrance When I try the command "grep -iR "127.0.0.1" /etc/apt/*" Nothing comes back. Thank you for the suggestion. I'm assuming that's what I need based on what I've googled. Sorry for the confusion
Terrance avatar
id flag
You shouldn't need a proxy set, unless you have one between you and the internet. One other search you can try on that system would be `sudo grep -iRE "localhost|127.0.0.1" /etc/*` since all configuration files should be somewhere in the `/etc/` directory.
01Tech avatar
so flag
@Terrace I get some results back. There is a character limit so I can't post it all. Is there a line you would like to search for specificly?
01Tech avatar
so flag
@Terrance /etc/dhcp/dhclient.conf:# option domain-name-servers 127.0.0.1; /etc/hosts:127.0.0.1 localhost /etc/hosts:::1 ip6-localhost ip6-loopback /etc/lvm/lvm.conf: # System IDs beginning localhost are not permitted. /etc/security/pam_env.conf:# to "localhost" rather than not being set at all /etc/security/pam_env.conf:#REMOTEHOST DEFAULT=localhost OVERRIDE=@{PAM_RHOST} /etc/security/pam_env.conf:#NNTPSERVER DEFAULT=localhost /etc/security/access.conf:#+:root:127.0.0.1 /etc/ssh/sshd_config:#X11UseLocalhost yes /etc/systemd/resolved.conf:#CacheFromLocalhost=no
cn flag
@01Tech If you want to practice how to set up a proxy server, you can of course do that. I haven't look at the tutorial you've linked in detail, so I can't say how good or bad it is. For anything else, I would agree with Terrance: So far, you haven't explained why you think you need `apt` to use a proxy in the first place. If there's no reason why `apt` can't (or shouldn't) connect to the internet directly, I wouldn't bother with a proxy (other than for learning purposes, see above).
01Tech avatar
so flag
@HenningKockerbeck The reason for it I guess is because when I googled my issue, that's what came up to solve the problem. It stated you need a proxy server to get apt updates and I'm just following those instructions. I don't know if this matters, but here is my setup: Ubuntu Server 22.04 via Virtual Box - I setup my Ubuntu Server with a static ip as I will be ssh-ing into the Ubuntu Server from MobaXterm. Which requires to use Adapter 1: NAT and Adapter 2: Host-only Adapter Check the main comment (I added my network interfaces)
01Tech avatar
so flag
@Terrance In the main question at the top, I added some of my setup information and network information if that helps bring some clarification.
01Tech avatar
so flag
@HenningKockerbeck In the main question at the top, I added some of my setup information and network information if that helps bring some clarification.
cn flag
@01Tech Typically, you _don't_ need a proxy server to get updates via `apt`. In case your system overall can't (or shouldn't, for example for security reasons) connect to the internet directly, you _can_ tell `apt` about an intermediary. That is a proxy server, which of course needs to exist somewhere, be reachable and so forth. If your system can connect to the internet in general, like for example to ping some website, I don't see a reason why you should need a proxy. And if your system _can't_ reach the internet directly, a proxy running on the server itself couldn't, either ;)
cn flag
@01Tech Maybe you want to ask a new question about your original issue (or check whether it has been asked and answered already).
cn flag
@01Tech I just saw that you changed the title of your question and with that, basically changed your question ;) I've added an answer to the new question.
Score:0
cn flag

Maybe it's useful to first summarize what a proxy server does. Very often, a system can connect to the internet directly. If that's the case, any program on that system can connect to the internet directly - a web browser, a mail client, apt or anything else.

But there are also cases where a system can't or shouldn't directly connect to the internet. That could be because of how the local network is set up, for security reasons, to filter out unwanted content like ads, to ensure compliance to some kind of regulations or for other reasons.

If that's the case, you can use a proxy server. A proxy server is an intermediate that connects to a destination somewhere in the internet instead of you. Say, you want to visit askubuntu.com in your web browser. If your system can connect to the internet directly, your browser can just connect to the server(s) askubuntu.com is running on:

Your system --> askubuntu.com

If your system can't or shouldn't connect to the internet directly, you can use a proxy server as an intermediate. A proxy server basically takes your request and sends it to the intended destination:

Your system --> Proxy --> askubuntu.com

Additionally, a proxy server can check whether the connection is allowed by some kind of company rules, filter out malware and other unwanted content or perform other services.

So, a proxy server is only needed if you can't or shouldn't access the internet directly - that goes for systems as a whole as well as individual programs like apt or others. Unless you have a specific reason to have apt use a proxy server, you don't need to.

If you do want apt to use a proxy server for a specific reason, you can do so with the Aquire configuration described in the tutorial that you linked. But in this case, obviously the proxy server you want apt to use needs to exist, to be reachable and so on.

01Tech avatar
so flag
I don't want to use a proxy server, I'm just going based off of what I googled around and seen come back as a resolution.
cn flag
Ok, let's got the very beginning of the matter: _Why_ do you think you need `apt` to use a proxy server? And I don't mean "because Google told me to" ;) What is the problem you wanted to solve at the very beginning of all this?
01Tech avatar
so flag
When trying to user "sudo apt update", I get the errors above. I want to be able to user "sudo apt update" without getting the connection errors I got above. I don't know any other reason for needing the proxy server besides what I seen searching my problem. I don't know how else to answer this. Which is stated here: https://linuxiac.com/how-to-use-apt-with-proxy/
cn flag
@01Tech Somehow, either `apt` specifically or your system as a whole tries to connect to `127.0.0.1:8080` for some reason. Please check the following: a) Does the name resolution work? Use `dig` to check what ip address `us.archive.ubuntu.com` resolves to. it shouldn't be `127.0.0.1`. b) Check if either the system as a whole or `apt` specifically already has a proxy configured somehow. For example, can you `ping` some site on the internet? What does `traceroute` for a site on the internet say? If either tries to connect to `127.0.0.1`, then that's the trail you need to follow further.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.