I have to use proxy servers to connect to the internet. I have set all proxies in my system proxy settings. Now I can connect to Internet using my browser and applications.

But I cannot connect to internet from my terminal.

I tried

export http_proxy="http://username:password@proxyserver:port/" 

But still terminal applications cannot connect to the internet.

  • 1
    Which command are you executing in Terminal to "connect to the internet"? Or how do you see that you are not able to connect?
    – nohillside
    Aug 22 '13 at 6:03
  • 1
    The proxy server(with no s) you are talking of here is relaying your web connexions, not all your Internet connexions. web connexions are using ports 80, 443…. Internet connexions may use all the remaining ports of the 65536 set. As an example an ssh connexion will use port 22 which won't go through your http proxy server. Hence the question of patrix to help you get a better answer.
    – dan
    Aug 22 '13 at 6:43
  • @patrix ping google.com
    – TLE
    Aug 22 '13 at 10:25
  • @TLE Ping is an exception to the rule and actually does not use the proxy at all, even if http_proxy is set. Ping expects a direct connection, and in a lot of cases when a proxy is being used, ping will fail although the proxy will still successfully connect. Aug 22 '13 at 10:46
  • 3
    try curl -o /dev/null www.google.com instead of ping
    – nohillside
    Aug 22 '13 at 10:57

Terminal does not use proxy settings configured in the network preferences pane because it doesn't do any connection. Terminal just let you fire commands which will use the network in different ways.

When setting your http_proxy and https_proxy environment variables should not include the http: or https: prefixes.

Therefore the environment variable in your case should read:


Note: many old programs have issues with connecting through proxy servers which require authentication before connecting.

Additional Tip:

Due to our infrastructure we found it much easier to have users run SquidMan locally and have it configured to connect to our main proxy. This allows the local machine to act as a proxy directly, and eliminates a lot of authentication issues etc when using proxy servers on Mac machines, especially in a mixed and AD environments.

In the case of using this method our http_proxy and https_proxy would be:

  • you mean I have to write export http_proxy="username:password@proxyserver:port"
    – TLE
    Aug 22 '13 at 10:24
  • @TLE Correct. Terminal does not need to know the protocol since it already knows it's a HTTP connection. Aug 22 '13 at 10:41
  • But still I am unable to connect to the Internet.
    – TLE
    Aug 22 '13 at 10:43
  • @TLE Then the problem most likely with the authentication. Try setting the proxy without including the username and password, which means you will be prompted for the information when trying to connect. It normally indicates the proxy itself does not support the connection from Terminal. We had a similar problem internally which is why I suggested the SquidMan solution. Aug 22 '13 at 10:45
  • still not working??
    – TLE
    Aug 22 '13 at 10:47

I recently ran into this issue and in searching found this post. Adding some points that were successful for me (on a Mac, using Terminal):

export http_proxy=http://username:password@proxyserver:port
export HTTP_PROXY=${http_proxy}

And for https:

export https_proxy=https://username:password@proxyserver:port
export HTTPS_PROXY=${https_proxy}

From this I was able to use git and brew without any problems (and authenticating through a proxy).


You can use the following command in the Terminal Window.

networksetup -setairportnetwork $Interface $ssID $Password

Here, $Interface is the "enX" style identifier for your AirPort card (usually en1, but it's en0 on MacBook Airs and en2 on Mac Pros, and can vary for other reasons as well)

$ssID is your network name, such as "Simon's SSID". Enclose it in quotes if it contains spaces.

$Password is your WEP, WPA-PSK, or WPA2-PSK password.

  • 1
    This configures the network, it does not allow the terminal itself to connect via a proxy. Aug 22 '13 at 7:57

You must log in to answer this question.

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