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'm trying to add the ppa repository (as a root) with the following command:

export HTTP_PROXY=""
add-apt-repository ppa:nilarimogard/webupd8

Traceback (most recent call last):
  File "/usr/bin/add-apt-repository", line 125, in <module>
    ppa_info = get_ppa_info_from_lp(user, ppa_name)
  File "/usr/lib/python2.7/dist-packages/softwareproperties/", line 84, in get_ppa_info_from_lp
pycurl.error: (56, 'Received HTTP code 407 from proxy after CONNECT')

Unfortunately it doesn't work. Looks like curl is connecting to the proxy, but the proxy says that Authentication is Required. I've tried with .curlrc, http_proxy env instead, but it doesn't work.

strace -e network,write -s1000 add-apt-repository ppa:nilarimogard/webupd8
connect(4, {sa_family=AF_INET, sin_port=htons(8080), sin_addr=inet_addr("165.x.x.232")}, 16) = -1 EINPROGRESS (Operation now in progress)
getsockopt(4, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
getpeername(4, {sa_family=AF_INET, sin_port=htons(8080), sin_addr=inet_addr("165.x.x.232")}, [16]) = 0
getsockname(4, {sa_family=AF_INET, sin_port=htons(46025), sin_addr=inet_addr("")}, [16]) = 0
sendto(4, "CONNECT HTTP/1.1\r\nHost:\r\nUser-Agent: PycURL/7.22.0\r\nProxy-Connection: Keep-Alive\r\nAccept: application/json\r\n\r\n", 146, MSG_NOSIGNAL, NULL, 0) = 146
recvfrom(4, "HTTP/1.1 407 Proxy Authentication Required\r\nProxy-Authenticate: BASIC realm=\"proxy\"\r\nCache-Control: no-cache\r\nPragma: no-cache\r\nContent-Type: text/html; charset=utf-8\r\nProxy-Connection: close\r\nSet-Cookie: BCSI-CS-91b9906520151dad=2; Path=/\r\nConnection: close\

Maybe it's because there is @ sign in the username? Wget works with proxy fine.

Related: How do I add a repository from behind a proxy?


Ubuntu 12.04

curl 7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/ libidn/1.23 librtmp/2.3

curl Features: GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP


When added credentials into .curlrc

cat ~/.curlrc 
proxy = 165.x.x.232:8080
proxy-user =

It seems to work for the plain curl.

curl | head

* Proxy auth using Basic with user ''
Proxy-Authorization: Basic cmFmYWwud2llY3pvcmVrQHVi...3R0RDA=
HTTP/1.1 302 Found


curl -v | head
* Establish HTTP proxy tunnel to
* Proxy auth using Basic with user ''
> Host:
> Proxy-Authorization: Basic cmFmYWwud2llY3pvcmVrQHVi...3R0RDA=
    > User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1     zlib/ libidn/1.23 librtmp/2.3
> Proxy-Connection: Keep-Alive
< HTTP/1.1 200 Connection established
* Proxy replied OK to CONNECT request
* successfully set certificate verify locations

But still doesn't work when adding ppa certificate.

pycurl.error: (56, 'Received HTTP code 407 from proxy after CONNECT')


Headers sent:

Proxy-Authorization: Basic cGVvcGxlcmVhbGx5c2hvdWxkQHNhbml0aXplcG9zdHM=
User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/ libidn/1.23 librtmp/2.3
Proxy-Connection: Keep-Alive


HTTP/1.1 200 Connection established


Headers sent:

User-Agent: PycURL/7.22.0
Proxy-Connection: Keep-Alive
Accept: application/json


HTTP/1.1 407 Proxy Authentication Required
Proxy-Authenticate: BASIC realm="proxy"

It seems that PyCURL doesn't re-send any Authorization when requested.

share|improve this question
Thanks, I've tried but this doesn't help. To make sure that this is not the case, I've included my credentials in .curlrc (without escaping @ seems to work for standard curl command), but not for pycurl. See the updated section. – kenorb Nov 5 '12 at 13:22
Thanks, I thought I missed something. I've reported the bug here: – kenorb Nov 5 '12 at 15:00
Have you also set https_proxy? See bug… – popey Dec 29 '12 at 19:08
Maybe it is a problem related to sessions and environment vars. You could try to export http_proxy and https_proxy in /etc/profile, then reboot the machine (if possible) and try it again. – jap1968 Dec 30 '12 at 21:50
Related to what jap1968 is saying above me, I'd made sure that both http_proxy and HTTP_PROXY are set (and https_proxy and HTTPS_PROXY). Thanks to Linux's case-sensitivity, those are actually two different variables - and, best of all, not all programs will use one or the other. Granted, it sounds more like an issue with how the username/password combination is being sent (because of '@'), but it's worth a shot anyway. – YellowApple Jan 22 '13 at 20:08
up vote 8 down vote accepted

Workaround if apt-get still works behind the proxy

  • add sources manually to /etc/apt/sources.list
  • add gpg key

Adding sources manually

I think on every ppa still contains a small description how to add sources manually. The launchpad site for your mentioned ppa ppa:nilarimogard/webupd8 is If you scroll down you see an expandable label Technical details about this PPA. If you expand it you find the description how to add sources manually. Add the following lines to mentioned /etc/apt/sources.list

deb quantal main 
deb-src quantal main 

Of course you have to adjust quantal to whatever version you are currently using.

Adding the Signing Key

The description also contains a signing key. This is important, so that your system can always verify that you actually access a trustworthy ppa-address. In case of your ppa that is 1024R/4C9D234C(can also be found under Technical details about this PPA), where the number behind the slash is important. You can add the fingerprint via the apt-key program. Typically you would perform the following command

 sudo apt-key adv --recv-keys --keyserver 4C9D234C

Adding if apt-key doesn't work through proxy

Since you already had problems with the add-apt-repository program this might not work either. So instead you can download and add the 1024 Bit key manually. If wget works you can do that in one step.

wget "" -O out && sudo apt-key add out && rm out

Otherwise safe "" in e.g. /path/key and use sudo apt-key add /path/key to add it.

Close with the usual

Afterwards you have to update the repository information apt-get update and then you should be able to download the packages.


My personal favorite on how to use the packaging mechanism (sadly in German):

The launchpad version also mentions all the important points:

Since it is untypical to use apt-key in the described way I only found the information in the man pages, man apt-key.

Related answer that pretty much describes the standard way to install ppa's manually:

share|improve this answer
@kenorb don't know if you get a notification if I edit my post, so: ping: "possible workaround" – LeoR Feb 6 '13 at 19:21
Thank you, so clear. – shgnInc Jan 12 '14 at 6:41
If your problem is that the port 11371 is blocked in your corporate firewall, you can now use the port 80 instead: "sudo apt-key adv --keyserver hkp:// --recv-keys 4C9D234C" – leszek.hanusz Feb 24 '14 at 9:51

Actually it seems to be much easier than the answer posted previously. You just need "sudo" to know that you are behind a proxy and it will work effortlessly. To do this, you need to export your proxy for http and https the way you usually do:

export http_proxy=http://username:password@host:port/
export https_proxy=https://username:password@host:port/

and then add Defaults env_keep="https_proxy" to then end of /etc/sudoers file. After this you should be able to add the ppa using the command:

sudo add-apt-repository ppa:the_ppa_you_want_to_add

or use

sudo -E add-apt-repository ppa:the_ppa_you_want_to_add

if you don't want to modify /etc/sudoers file. The -E option exports environment variables to the sudo user.

I have given a detailed description about this here on my blog.

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.