38

I am trying to setup an HTTP proxy on a Windows machine. Problem is, the password has a special character (@) in it that is causing the set command to fail.

I have tried both escaping the character (\@) and percent-encoding it with the hex value (%40), to no avail.

For example, with the username Foo and password B@r, I have tried the following commands:

set http_proxy=http://foo:B\@[email protected]:80
set http_proxy=http://foo:B%[email protected]:80

Other than changing the password how can I have the proxy use the password?

5
  • Is the set failing or is the tool using the http_proxy environment variable failing due to the @ symbol? Apr 22, 2011 at 13:16
  • Yes. Because the format is username:password@server:port, having @ in the middle of your password causes the right hand side of your password to be considered the hostname, thus the hostname resolution above fails because it thinks the hostname is [email protected]. The "r@" should not be there. Nov 3, 2011 at 16:23
  • 3
    I tried using %40 and it worked (on Windows), are you sure? Oct 29, 2012 at 2:32
  • In fact, it works on both Windows and Linux (Ubuntu). Oct 29, 2012 at 2:55
  • duplicate stackoverflow.com/questions/6172719/…
    – rofrol
    Aug 3, 2015 at 11:41

4 Answers 4

50

You have to percent-encode | encode the special characters. E.g. instead of this:

http://foo:B@[email protected]:80

you write this:

http://foo:B%[email protected]:80

So @ gets replaced with %40.

Note: foo = username, b@r = password, http-gateway.domain.org = host proxy to connect

3
  • 2
    encoding is indeed the way to get around this problem (and many others).
    – HTDutchy
    Jan 11, 2013 at 12:00
  • i found that i needed to double urlencode some characters
    – dovidweisz
    Nov 2, 2016 at 17:33
  • 3
    I suggest simply using javascript encodeURIComponent() to this purpose. You can easily use your browser's DeveloperTools -> Console. Nov 26, 2018 at 4:39
3

For any special characters, in username or password, we can always use UTF-8 encoded strings in its place. For example: ! can be replaced with %21

so the command would be, if password is abc!:

npm config set proxy http://user:abc%[email protected]:8080/

npm config set https-proxy http://user:abc%[email protected]:8080/

2

Use %Ascii code of the special character in hexadecimal notation for any special character. Suppose My password is AB@12#& then the password should be set as

git config --global http.proxy *http://usernamne:**AB%4012%23%26**@myipadress:portnumber*

Refer to ascii table for knowing the hexadecimal ascii code of any number.

-1

Based upon this answer on SO, can you try using ^ to escape the @ symbol?

3
  • In response to both, the set is successful, it is the tool using the environment variable: set http_proxy=http://foo:B^@[email protected]:80 jruby -S gem install rake ERROR: While executing gem ... (URI::InvalidURIError) the scheme http does not accept registry part: foo:B@[email protected]:80 (or bad hostname?) Apr 22, 2011 at 15:05
  • This is a Linux based question, not a Windows based question, using ^ doesn't work for me. I still get wget: unable to resolve host address [email protected]'` after setting the proxy environmental variable. Nov 3, 2011 at 16:19
  • 2
    Actually it IS a Windows based question...I know pyropenguin personally. Nov 7, 2011 at 18:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .