I'm trying to disable the proxy for apt-get but it seems like apt-get gets it's proxy configuration from somewhere else other than /etc/apt/apt.conf, because although the apt.conf file is empty (and the system proxy set to None) it's still trying to connect to the proxy.
Anyone got an idea?
7 Answers
I'm using a script to replace different configuration files in order to easily switch between proxy and non-proxy environements. The problem was that I replaced the proxy apt.conf file with an empty apt.conf file, which apt then ignored.
Works for current latest Ubuntu as well.
If the proxy conf does not exist, create it:
$ sudo touch /etc/apt/apt.conf.d/95proxy.confThen add the following two lines:
Acquire::http::Proxy "false";
Acquire::https::Proxy "false"; 5 If you do not want apt-get to use a proxy,
use apt-get as:
sudo apt-get -o Acquire::http::proxy=false <update/install> 2 Sometimes, there are proxy environment variables that are still set.
To find out, do the following command:
env | grep proxyIf you see some output, for example:
http_proxy=Then you'll need to unset this variable.
To do so, execute the following command:
unset http_proxyFollow the same approach for all the other entries, such as https_proxy.
There isn't only one place where apt-get read configuration files. You should run grep -i proxy /etc/apt/apt.conf.d/* and it will give you the exact file that has the proxy settings (this is just an example running with update instead proxy:
grep -i update /etc/apt/apt.conf.d/*
/etc/apt/apt.conf.d/20apt-show-versions:// When Apt's cache is updated (i.e. apt-cache update)
/etc/apt/apt.conf.d/20packagekit:// Whenever dpkg is called we might have different updates
/etc/apt/apt.conf.d/20packagekit:// i.e. if an user removes a package that had an update
/etc/apt/apt.conf.d/20packagekit:"/usr/bin/test -e /usr/share/dbus-1/system-services/org.freedesktop.PackageKit.service && /usr/bin/test -S /var/run/dbus/system_bus_socket && /usr/bin/gdbus call --system --dest org.freedesktop.PackageKit --object-path /org/freedesktop/PackageKit --timeout 1 --method org.freedesktop.PackageKit.StateHasChanged cache-update > /dev/null; /bin/echo > /dev/null";
/etc/apt/apt.conf.d/20packagekit:// When Apt's cache is updated (i.e. apt-cache update)
/etc/apt/apt.conf.d/20packagekit:"/usr/bin/test -e /usr/share/dbus-1/system-services/org.freedesktop.PackageKit.service && /usr/bin/test -S /var/run/dbus/system_bus_socket && /usr/bin/gdbus call --system --dest org.freedesktop.PackageKit --object-path /org/freedesktop/PackageKit --timeout 1 --method org.freedesktop.PackageKit.StateHasChanged cache-update > /dev/null; /bin/echo > /dev/null"; 1 It's possible the environment variable http_proxy is set to some proxy. try clearing the variable (or at least look if it has a value)
Stupid way of making it work is disable the proxy for a while using system settings > Network .
Or remove the proxy config from /etc/environment and /etc/apt/apt.conf
And add the manual proxy config back once you need proxy back.
1For me, no proxy variables were set in the environment, and no proxy was set at the system level. However, a file 01proxy was present in /etc/apt/apt.conf.d/ which contained the line Acquire::http::Proxy "";. Commenting the line with # (or deleting the file) worked for me. This means that other files in apt.conf and apt.conf.d may contain proxy settings and I'd suggest greping proxy (with -i flag) information from those two folders to know if the apt service uses one.
Note that @Prashant Adlinge answer always works in that case as it bypasses any configuration file.