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

I want to add SOCKS proxy settings to /etc/apt/apt.conf. What is the syntax for it? Is it same as http and ftp syntax?


share|improve this question
up vote 12 down vote accepted

A possible solution can be to use tsocks, an application that can redirect the network traffic through a socks proxy. Install tsocks package, modify /etc/tsocks.conf to set address and port number of your socks proxy, and run:

$ sudo -s
# tsocks apt-get update
# tsocks apt-get dist-upgrade
# exit


$ sudo -s
# . tsocks -on
# apt-get update
# apt-get dist-upgrade
# . tsocks -off # not really necessary, given the exit
# exit

You can think to a number of options, to simplify and automate its use.
Don't forget the leading dot, the Manpage has more deatails on this.

Edit: a shorter way to use it:

$ sudo tsocks apt-get update
$ sudo tsocks apt-get dist-upgrade
share|improve this answer
thanks. will try that out! – Ubuntuser Apr 15 '11 at 15:41
It seems tsocks is not installed by default, so I need to run sudo tsocks apt-get install tsocks. Hahahahahaha... – BornToCode Apr 12 at 7:21
You can use curl to download tsocks, install it and then use :) – neutrinus May 20 at 20:38

Or tou can put in your /etc/apt/apt.conf something like this:

Acquire::socks::proxy "socks://user:pass@host:port/";
share|improve this answer
This doesn't seem to work in Ubuntu 12.04 – Shnatsel Oct 16 '13 at 17:38
Works in 13.10. – isaaclw May 2 '14 at 4:11
I'm pretty sure this is wrong syntax, it means "proxy all URLs that begin with socks:// through socks://user:pass@host:port/". Really, it should be this: Acquire::http::proxy "socks://user:pass@host:port/"; – Hans-Christoph Steiner Jul 18 '14 at 16:03
@Hans-ChristophSteiner: This makes a connection to the indicated host and port, but the connection does not use the socks protocol. It looks like a http proxy protocol, but I did not check with an actual http proxy. – Seth Robertson Apr 16 '15 at 0:02
At this point, I'm sure that Acquire::socks is for setting the proxy for URLs that start with socks://. So that means you don't need a proxy to access the internet, and apt is not using any proxy for ftp://, http://, or https://.. apt only supports HTTP proxies, i.e. Acquire::http::proxy "http://localhost:8118. – Hans-Christoph Steiner Sep 8 '15 at 19:38

Using the next config line works for me:

Acquire::socks::proxy "socks5://server:port";

To keep apt.conf clean and avoid problems at Linux upgrade I created a new file (/etc/apt/apt.conf.d/12proxy) and added the config file to it.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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