Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
apt-get does not work with proxy

I have tried changing my proxy settings in a terminal as:

export HTTP_PROXY=


export http_proxy=

but when I try to install a new package or update apt-get, apt-get starts displaying messages from which it seems it is trying to connect to a previously set proxy:

sudo apt-get update  
0% [Connecting to (] [Connecting to (

I have tried setting the proxy via bashrc file but that din work either. As far as I remember was set using GNOME GUI but I don't have access to the GUI right now so I am trying to set it from terminal.

share|improve this question

marked as duplicate by fossfreedom Jul 2 '12 at 19:00

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

you can add proxy in /etc/apt/apt.conf – Piyush Jul 2 '12 at 8:48
@piyush Will that not only allow apt-get to access the web though..? If he wants to be able to access web with anything else he needs to enter it into /etc/bash.bashrc – LinuxBill Jul 2 '12 at 8:52
true, I suggested that seeing him try to do sudo apt-get update – Piyush Jul 2 '12 at 8:54
sudo -E apt-get WHATEVER works in my case (given that http_proxy is already exported as an environmental variable). – Janaka Bandara Mar 14 '15 at 4:03
Just a general tip -- when doing these updates, you may need to log out and back in before they start working. That's what I had to do. – kayleeFrye_onDeck Jul 1 at 0:00

The file:


Is the correct place to specify system-wide environment variables that should be available to all processes. See for details. Note that this is not a script file but a configuration file.

If you want this for the specified command only, use (as root):

http_proxy= apt-get update
share|improve this answer
Great! Saved much of my time :) – Arun Jul 11 '13 at 10:12
It is so good. thank you. It is just for temporary usage, Isn't it? – shgnInc Oct 17 '13 at 5:45
+1 this worked for me on ubuntu 12.4 – isJustMe Dec 4 '13 at 22:26
Alas still not yet for Firefox 37.0.2. – user643722 May 12 '15 at 16:15
up vote 27 down vote accepted

Okay just solved it. Adding following line to /etc/apt/apt.conf has solved the problem: Acquire::http::proxy "";

If file does not exist, create it. Do not confuse it with apt.conf.d directory.

share|improve this answer
Great. The reason your manual export failed to affect apt-get is because sudo ignores that environment variable by default (i.e. it doesn't pass it on to the command). For one-off runs, you could do sudo env http_proxy= apt-get update. Otherwise, you could configure sudo to allow http_proxy to fall through. – geirha Jul 2 '12 at 10:08

Edit your:

gedit /etc/profile

Enter the details in this format.

export http_proxy=http://username:password@proxyhost:port/ 
export ftp_proxy=http://username:password@proxyhost:port/

Then run the

sudo apt-get update

That should do it for you.

As stated above you can enter the proxy into apt.conf (Piyush Credit)

share|improve this answer
I have mentioned in my question that I tried setting the proxy via bashrc file and then tried source /etc/bash.bashrc but apt-get is still trying to access the old repository. – baltusaj Jul 2 '12 at 9:45
Besides that, /etc/bash.bashrc is the wrong place to set environment variables as it will only affect bash run interactively. Environment variables should be set in /etc/environment or /etc/profile. – geirha Jul 2 '12 at 10:05
Thanks I will update my answer. – LinuxBill Jul 3 '12 at 9:14

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