My proxy server password has special characters such as !,@, and so on. How do I set and export the variable called http_proxy or HTTP_PROXY when password has special characters under Unix like operating systems?

If your password is F@o:o!B#ar$ and set http_proxy as follows:

export http_proxy="http://user:F@oo!B#ar$"

Tutorial details
Difficulty level Easy
Root privileges No
Requirements Bash/ksh/Unix
Est. reading time N/A
You may get the error due to special characters. The solution is to use unicode characters in hexadecimal. You can use command line tool such as unum or gnome-character-map to convert special characters into hexadecimal unicode.


Convert @:!#$ into equivalent hexadecimal unicode using unum command:
$ unum '@:!#$'
Sample outputs:

   Octal  Decimal      Hex        HTML    Character   Unicode
    0100       64     0x40       @    "@"         COMMERCIAL AT
     072       58     0x3A       :    ":"         COLON
     041       33     0x21       !    "!"         EXCLAMATION MARK
     043       35     0x23       #    "#"         NUMBER SIGN
     044       36     0x24       $    "$"         DOLLAR SIGN

In this example @ becomes %40, : becomes %3A, and so on. Find and replace all special characters with unicode hexs. Find:
Replace with:
Finally, set and export http_proxy, HTTP_PROXY in the following format:

export http_proxy=""

Test it:
$ curl -I
$ wget

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 6 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
6 comments… add one
  • Munesh May 4, 2015 @ 4:30

    How should I write my username and passowrd
    username is itibri\t68
    and password is 2008

  • MV Aug 26, 2015 @ 15:24


    This is exactly what I needed

  • Francis Sep 17, 2015 @ 16:37

    Show man, thanks.

  • Irfan Jan 5, 2016 @ 8:36

    Thanks bro. Its working like a charm. I was facing this problem since years and I gave up. Now its working. Thank You.

  • zw963 Jan 10, 2016 @ 11:43

    It not work for me.

  • zw963 Jan 10, 2016 @ 11:44

    Not worked for me in linux mint 17.3.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum