How To: Use apt-get behind proxy

If you run your Ubuntu system behind a firewall and have to use proxy server for http and ftp access, then your apt-get on a newly installed Ubuntu system will probably not work.

To make it use proxy, simply set the http_proxy environment variable. Once you get it working (try something like apt-get update), you'll probably want to add it to your .bashrc file.

Setting the http_proxy variable

Here's how you set the variable:

bash$ export http_proxy=http://proxy:8080

If you're required to use your username and password for your proxy, they can be specified this way. Obviously, port 8080 can and should be replaced with the valid port for your proxy server (sometimes it's 3128):

bash$ export http_proxy=http://username:password@proxy:8080

Related books

If you want to learn more, here's a great book:


ubuntu-kung-fu-practical-guide

Ubuntu Kung Fu

Please share:
  • Digg
  • del.icio.us
  • Netvouz
  • BlinkList
  • Fark
  • Furl
  • kick.ie
  • Netscape
  • Reddit
  • StumbleUpon
  • Technorati
  • YahooMyWeb

9 comments ↓

#1 List Installed Packages on Your Ubuntu Linux | UNIX Tutorial: Learn UNIX on 09.02.08 at 4:49 pm

[...] apt-get behind proxy Please share: These icons link to social bookmarking sites where readers can share and discover new web pages. [...]

#2 Dean on 10.30.08 at 5:52 pm

This did not work for me.

#3 Dean on 11.21.08 at 5:41 am

The author of this article was very kind to help me resolve this, which was so nice! My install of kubuntu didn't accept web based updates to apt-get, because I was behind a proxy, and commented them out of /etc/apt/sources.list, which the author helped me figure out. Cool!

#4 Gleb Reys on 11.21.08 at 11:18 am

Always a pleasure to help, Dean!

#5 Thushara on 01.09.09 at 6:21 am

It's working. Thnx. Ummmmmmmmah

#6 Gleb Reys on 01.09.09 at 4:28 pm

Such a simple fix, and such a relief when it finally works. Glad your problem is sorted!

#7 Shrik on 04.22.09 at 12:27 pm

Doesn't work for me; i get the error 407 Proxy Authentication required

#8 Gleb Reys on 05.09.09 at 1:54 am

Hi Shrik,

This is because your proxy server is password protected – not much you can do unless you specify your credentials.

#9 Ubuntu SSH: How To Enable Secure Shell in Ubuntu | UNIX Tutorial: Learn UNIX on 05.15.09 at 9:57 pm

[...] Using apt-get behind proxy [...]

Leave a Comment