In this tutorial, I will show you how to set up http_proxy or https_proxy when your username or password contains special characters such as comma, @, #, etc.
Error: Unable to set http_proxy or https_proxy with special characters in username or password.
Usually when exporting http_proxy or https_proxy we have to provide username and password along with proxy IP address and port.
This will work in most cases, but if the username or password contains some special characters, you might get an error:
Resolving s... failed: Name or service not known. wget: unable to resolve host address “s”
The error output may vary depending on the character used in the username or password. There are two ways to overcome this error:
Solution-1: Convert text to hex Unicode
You must match the “hex Unicode” values of the corresponding special characters in the proxy username and password. For a list of Unicode character collations, go to:
For example, a password like “P @ $$ / / 0, #” can be converted to
P ⇒ P <- поиск не требуется @ ⇒ 0x40 $ ⇒ 0x24 $ ⇒ 0x24 ⇒ 0x5C / ⇒ 0x2F ⇒ 0x5C / ⇒ 0x2F 0 ⇒ 0 <- поиск не требуется , ⇒ 0x2C # ⇒ 0x23
So if we combine this for “” P @ $$ / / 0, # “, we get “P0x400x240x5C0x2F0x5C0x2F00x2C0x23”
Now you can export your http_proxy:
# export http_proxy="http://username:[email protected]:port/"
Similarly for exporting https_proxy
# export https_proxy="https://username:[email protected]:port/"
Solution-2: provide username and password using wget
Instead of performing the conversion, you can also provide the username and password in plain text using the wget command. From the wget man page:
--proxy-user=user --proxy-password=password Specify the username user and password password for authentication on a proxy server. Wget will encode them using the "basic" authentication scheme.
This solution is only valid if you plan to use wget or use a system-wide proxy, you can use Solution 1, where the username or password contains any special characters.
In this tutorial, I shared the steps to set up http_proxy and https_proxy when the username and / or password section contains any special characters.
On the provided Unicode page, you can search for your character and then find the Unicode hex value for the corresponding character.
Then just replace the special character with the Unicode value and you can export the proxy on your Linux server.