How to configure http proxy exceptions on Linux

When you are behind HTTP proxy, you need to configure proxy settings for your applications in one way or another. Typically you define http_proxy environment variable pointing to your proxy, so that all HTTP requests go through the proxy. But what if you want to bypass HTTP proxy for specific destination web servers? That's when you need to configure HTTP proxy exceptions.

On Linux, you can define HTTP proxy exceptions via "no_proxy" environment variable. In "no_proxy" variable, you specify a list of domain names or IP addresses for which HTTP proxy should not be used. Along with domain names or IP addresses, you can also specify port number if necessary.

If you would like to define HTTP proxy exceptions system wide, do the following.

On Ubuntu, Debian or Mint:

$ sudo vi /etc/environment
no_proxy=", localhost, *,,"

On CentOS, Fedora or RHEL:

$ sudo vi /etc/profile.d/
export http_proxy=""
export no_proxy=", localhost, *,,"

The above example means that if you are reaching local host (e.g.,, localhost), *,, or a host with IP address, you will not use HTTP proxy. For all other destinations, you will use the designated HTTP proxy (

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.

Support Xmodulo

Did you find this tutorial helpful? Then please be generous and support Xmodulo!

The following two tabs change content below.
Dan Nanni is the founder and also a regular contributor of He is a Linux/FOSS enthusiast who loves to get his hands dirty with his Linux box. He likes to procrastinate when he is supposed to be busy and productive. When he is otherwise free, he likes to watch movies and shop for the coolest gadgets.

One thought on “How to configure http proxy exceptions on Linux

  1. Hi Dan,

    Thank you for the information. Just a quick question: when a Linux box is behind a proxy which requires Windows domain credentials, say Forefront TMG, proxy configuration becomes a mess.

    You can go edit /etc/profile.d/ to include
    export proxy_password=12345678
    export http_proxy="http://$proxy_username:$proxy_password@"
    export https_proxy="https://$proxy_username:$proxy_password@"

    However when you echo $proxy_username, you receive Even if you


    echo $proxy_username returns and thus does not authenticate with the proxy server.

    Any ideas?

    Thank you,

Leave a comment

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