I just updated from Ubuntu 12.04 to 13.10

In 12.04, I used to set up my http_proxy variable in .bashrc and then use apt-get as follows

sudo -E apt-get update

The -E option in sudo used to make the user environment variables available to sudo and apt-get would pick up the http_proxy variable.

For some reason, this method is not working in 13.10. I am repeatedly getting 407 Proxy authentication Required.

Does anybody know the reason why? How do I solve this?

I know that the other way to enable proxy for apt-get is to change settings in apt.conf. I don't want to do this as this will create a system wide setting. Also, when I am using the system at home (where there is no proxy), I will again have to go and change apt.conf.
In the above solution, I would just have to drop the "-E" option in sudo and apt-get will just attempt to directly connect to the internet.

  • 1
    The 407 error indicates apt-get is using the proxy but the username and password required are not provided or are invalid. Are you sure you added the proxy this way: export http_proxy='username:password@host:port;? And if yes, are you sure you have escaped special characters like @ and :, if you have them in your password?
    – jobin
    Nov 11, 2013 at 5:30
  • Yes, I have an @ in my password and I have escaped it with %40. The same proxy is working in firefox. So, I don't think the problem is because of authentication. There is something going wrong when apt-get is getting the proxy variables
    – Hashken
    Nov 11, 2013 at 5:39
  • 1
    The better way of escaping characters is using a \`, though I am not sure what %40` is. Try using \` before the @` in your password.
    – jobin
    Nov 11, 2013 at 5:41
  • If you want to test, try wgeting something and see if it works.
    – Braiam
    Nov 11, 2013 at 5:43
  • %40 is the HTML encoding for @. This used to work in 12.04. wget works with this too. Anyways, I tried esaping with \. Wierdly even wget does not work with this.
    – Hashken
    Nov 11, 2013 at 5:49

1 Answer 1


You should provide your proxy with the authentication parameters in your /home/$USER/.bashrc file as export http_proxy=http://username:password@host:password/.

If you have special characters(non-alphanumeric characters) like ", ', @, : etc. in your password, you should use the HTML codes for the characters instead.

For example, if you password is p@ssw0rd, you should type the password as p%40ssw0rd in the /home/$USER/.bashrc file and then export these variables to the current session as source /home/$USER/.bashrc. (%40 is the HTML code for @.)

  • Yes, I have done that and I am able to use wget perfectly with it. The only problem is with apt-get, may be because it is being run with sudo. Sudo needs to pass on the environment variables to apt-get and this is what -E was doing. But now it doesn't seem to work
    – Hashken
    Nov 11, 2013 at 5:53
  • What do you get when you do a sudo -E echo $http_proxy?
    – jobin
    Nov 11, 2013 at 5:56
  • When I do sudo -E echo $http_proxy, I get the proper value of the proxy that I had assigned. The weird part is that even sudo echo $http_proxy (without -E) produces the same result. My understanding is that it shouldn't.
    – Hashken
    Nov 11, 2013 at 6:01
  • Sincerely, no idea what's happening :(
    – jobin
    Nov 11, 2013 at 6:09
  • For some weird reason there was a wrong acquire proxy setting in my apt.conf. This was causing all the problems. Now, apt is working as expected. Thanks for your effort.
    – Hashken
    Nov 11, 2013 at 6:39

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.