59

For the command

sudo apt-get update

I get following error:

W: Failed to fetch http://ch.archive.ubuntu.com/ubuntu/dists/maverick-updates/multiverse/binary-i386/Packages.gz  
407  Proxy Authentication Required (The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. )

I am running Ubuntu 10.10 installed on Windows XP using VirtualBox. For Internet connections I am using proxy server with an authentication. I tried to use gnome-network-proxy tool to set proxy settings system-wide.

After that /etc/environment has been updated by http_proxy variable with the format http://my_proxy:port/, there were no authentication data.

I checked this with Firefox. Browser asked my for login and password and everything was working fine. It was unfortunately not the case for apt-get. I have also tried to do as described here. Unfortunately it does not work.

May it be somehow related to the fact that a proxy is in a Windows domain, any ideas?

My proxy name is http-proxy. Is '-' a special character here?

2
  • 2
    Have you used the global network proxy under system --> preferences --> network proxy, and applyed the settings globaly? May 3, 2011 at 9:49
  • You could try the easy to use GUI tool GrrProxy Mar 21, 2015 at 18:17

12 Answers 12

59

For my corporate network I was given by my administrator the proxy name in the format:

http://[username]:[password]@[proxy-webaddress]:[port]

For our Windows network our username is in the format:

[domain]\[username]

For example:

http://mywindowsdomain\fossfreedom:password@askubuntu-proxy.com:8080

This was added to the following NEW file (it doesnt exist by default):

gksudo gedit /etc/apt/apt.conf.d/01proxy

The following text was added:

Acquire::http::Proxy "http://mywindowsdomain\fossfreedom:password@askubuntu-proxy.com:8080";

If you are using an anonymous proxy then you don't need your login credentials:

Acquire::http::Proxy "http://askubuntu-proxy.com:8080";

Save the file and then checked that all was ok with:

sudo apt-get update
6
  • To those who will read this later: This seem like a hack to the untrained eye, but it is an incredibly simple way to get the corporate proxy to obey.
    – macduff
    Jun 26, 2012 at 19:55
  • 2
    This works perfectly. UNLESS you have earlier set the /etc/apt/apt.conf with a bad Acquire line. I did just that, and all I had to do was go back and delete that line. Aug 17, 2012 at 13:44
  • On Ubuntu 12.10, I had to copy the changes made to /etc/apt/apt.conf.d/01proxy to /etc/apt/apt.conf before it would work. Mar 26, 2013 at 19:18
  • even with these edits I couldn't get this to work for me with 12.04... but I managed to get this to work by using and configuring ntlmaps and pointing the apt.conf file to the intermediate proxy there.
    – monkut
    May 2, 2013 at 7:54
  • The program 'gksudo' is currently not installed. You can install it by typing: sudo apt-get install gksu (which of course won't work without a proxy set up ...) Fortunately sudo works just fine.
    – T.E.D.
    Dec 30, 2015 at 17:04
13

I have found that USERNAME and PASSWORD entered into the "Network Proxy" applet does not get stored into the apt.conf file you must manually add the username and password in the /etc/apt/apt.conf file.

The "Network Proxy" applet only stores the hostname and the port.

The basic syntax is

Acquire::http::proxy "http://User:Password@host:port/";

Acquire::ftp::proxy "ftp://User:Password@host:port/";

Acquire::https::proxy "https://User:Password@host:port/";

If you are using Windows usernames and password follow this advice:

User = Domain/Username

(windows users use / not \)

If you are using Windows strong/complex password with special characters you must use the URL encoding for the values, for example an "@" in the password would be "%40".

1
  • 1
    (windows users use / not ) So THAT's why I'm stuck :) Thanks! May 19, 2012 at 5:35
9

Try setting http_proxy to http://user:pass@proxyserver:port/

edit:
If setting http_proxy does not work try editing apt.conf. In
Ubuntu apt.conf is fragmented in /etc/apt/apt.conf.d/ directory.
In this directory edit /etc/apt/apt.conf.d/01ubuntu:

APT {
    Acquire {
        http {
            Proxy "http://user:password@server:port";
        };
    };
};

or try setting it using Synaptic: Settings -> Preferences -> Network
And then set your proxy settings in "Manual proxy configuration".

6
  • 3
    Do you mean /etc/environment file ?
    – tommyk
    Jan 28, 2011 at 12:46
  • Yest, it will set this variable globally. Jan 28, 2011 at 18:02
  • How would one encode the colon as part of the password?
    – k0pernikus
    Dec 19, 2011 at 9:34
  • /etc/environment is not working with apt-get (or at least it requires restart ;), changing apt.conf has immediate effect May 22, 2012 at 13:56
  • I can confirm setting "Manual proxy configuration" and "Apply system wide" in Network works with apt-get. Mar 10, 2014 at 14:41
5

I'm behind a MS ISA proxy and I'm using Cntlm Authentication Proxy; in the apt.conf I have 4 lines; I've read somewhere that the last line must be empty, but I'm not sure about it. It works perfectly:

Acquire::http::proxy "http://127.0.0.1:3128/";
Acquire::ftp::proxy "ftp://127.0.0.1:3128/";
Acquire::https::proxy "https://127.0.0.1:3128/";
3

cntlm has a discovery option that helps find the right config to work with the NTLM auth of your network, try this:

cntlm -I -M http://test.com

copy and paste the results in /etc/cntlm.conf

restart cntlm

1
  • 'cntlm' is currently not installed. You can install it by typing: sudo apt-get install cntlm (which if course won't work if my proxy isn't set right...)
    – T.E.D.
    Dec 30, 2015 at 16:48
2
  1. Open terminal and add the following lines to /etc/apt/apt.conf.

    gksu gedit /etc/apt/apt.conf
    
  2. Add these 2 lines:

    Acquire::http::Proxy "http://user:pass@proxy-host:port/";
    Acquire::ftp::Proxy "http://user:pass@proxy-host:port/";
    
  3. Save and exit.

    Now apt-get update and should work behind a proxy, but you will notice that still something is not working, that is the add-apt-repository command.

    To be able to add repository behind a proxy, type the following commands:

    # export https_proxy="http://192.168.1.5:8080"
    # sed -i 's/"keyserver.ubuntu.com"/"hkp://keyserver.ubuntu.com:80"/' /usr/share`/pyshared/softwareproperties/ppa.py`
    

    Now you can add repositories in Lucid and Natty using LANG=C add-apt-repository

    Example:

    root@ubuntu:~# LANG=C add-apt-repository ppa:motumedia/mplayer-daily

Via Unixmen

2

How to apply apt-get update or install in Ubuntu ? I was behind a proxy server and after installing Ubuntu i coulden`t update or install anything using the apt-get command. After searching i found that The apt package has been changed, now there is no more apt.conf on /etc/apt directory.

What i did to resolve this issue is the follow :

Open terminal and the file

sudo -H gedit /etc/bash.bashrc

and add at the bottom of the file these 2 lines :

#proxy 
export http_proxy=http://user:password@host:port/
export ftp_proxy=http://user:pass@host:port/

Now save and exit, Now you will be able to update, upgrade or install packages in Ubuntu

3
  • I have added exports as you suggested. It still does not work. Now I got a different error message "Could not connect to extras.ubuntu.com:80 (91.189.88.33). - connect (110: Connection timed out)". <br> Strange thing is that when I enter the same proxy settings in Firefox preferences then I can browse a web.
    – tommyk
    Jan 28, 2011 at 13:58
  • @tommyk could you post your /etc/apt/sources.list and update your question here or try to delete extras.ubuntu.com from your /etc/apt/sources.list and execute apt-get update
    – hhlp
    Jan 28, 2011 at 14:16
  • I've replaced my sources.list with a default one from ubuntu web page. I still got the same error for every repository listed in a this file.
    – tommyk
    Jan 28, 2011 at 15:09
2

This one has been working for me!!

(adding proxy manually from the GUI via system-settings->network etc should work) But if doesn't and you export env variable from the terminal:

export http_proxy=http://<your proxy url>:<proxy port>

and again for https:

export https_proxy= <usually the same as the http>

Most important to add the -E: To run sudo apt-get install or sudo apt-get update you must run:

sudo -E <command>

The "-E" use your user environment variables for the root (sudo) , for that matter the http_proxy/https_proxy you've just exported.

Hope it helps :)

1

With a BlueCoat proxy, for me the format of the apt.conf file was required to look like:

Acquire::http::proxy "http://Domain%5cUserID:Password@proxy.name.whatever:80/";
Acquire::ftp::proxy "ftp://Domain%5cUserID:Password@proxy.name.whatever:80/";
Acquire::https::proxy "https://Domain%5cUserID:Password@proxy.name.whatever:80/";

^ ^ ^ ^ Blank line after 3rd proxy line, do not enter this line. ^ ^ ^ ^

1

This one-liner solution worked for me:

sudo env http_proxy=http://<ip>:<port> apt-get update
1
  • alse works for me at ubuntu 18.04
    – djy
    Sep 5, 2022 at 2:29
1

Had this same issue after installing Ubuntu 18.04. What worked for me was to:

  1. Open Network Proxy screen in Network settings
  2. Select Manual and adding both http and https proxy info
  3. Additionally set Ignore Hosts field with:
    https://extensions.gnome.org*, *.extensions.gnome.org*
  4. Restarted Ubuntu

As for point 3, not sure if adding the above entry works or not but this step works for me

0
  1. Start Synaptic (go to System -> Administration -> Synaptic in Gnome 2, or type "synaptic" in the Dash in Unity).
  2. On the menu bar, click Settings, followed by Preferences.
  3. When the Preferences window appears, click on the Network tab.
  4. Select the Manual proxy configuration radio button and enter your proxy information.
  5. To apply authentication information, click the Authentication button and enter username and password.
  6. Click OK to close the HTTP Authentication window.
  7. Click OK to close the Preferences window.
  8. Click the Reload button to update the package lists.

Note that this setting change will also affect the Update Manager.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.