See all Squid related FAQ
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 Linux, macOS, FreeBSD, OpenBSD, NetBSD or Unix-like operating systems?

Tutorial details
Difficulty level Easy
Root privileges No
Requirements Linux terminal
Category Commands
OS compatibility BSD Linux macOS Unix WSL
Est. reading time 2 minutes
Say, your password is F@o:o!B#ar$, then you can set http_proxy as follows on your Unix or Linux machine:

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

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.

How to set http_proxy with special characters in password Under Unix / Linux

The unum command is a free and open-source command-line utility. It allows you to convert decimal, octal, hexadecimal, and binary numbers Unicode character and block names and HTML/XHTML character entity names into one another. It can be used as an online particular character reference for Linux and Unix CLI users. Let us see some examples:


Convert @:!#$ into equivalent hexadecimal unicode using unum command:
$ unum '@:!#$'
Here is what I see:

   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 using the export command:

export http_proxy=""

You can set https_proxy too. Then, test it:
$ curl -I
$ wget

Summing up

It was a little tricky to get around this problem. But, as they say, Linux and Unix CLI and shell users always find a way to solve any problems. Thanks to the unum command. It was an easier task. Do check the following manual pages using the man command/info command or help command:
$ man unum
$ man bash
$ man curl
$ man wget

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

7 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.

  • Damz Mar 23, 2022 @ 14:21

    This was really helpful! Thank-you so much as I have been struggling with this for almost a year

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.