Sign up ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

My MacBook in office does not have internet access. So I set up an instant SOCKS Proxy over SSH to surf the web.

However, when I try to add an entry to /etc/hosts, the browser does not go to the site I expected ...

My MacBook's WIFI is off and is connected to the company LAN:

 IP address:
 Subnet mask:
 DNS server:

Be default, there is not internet access.

There a Linux development box ( which has access to the internet, so I set up an instant SOCKS proxy to gain internet access for my MacBook:

 ssh -fND localhost:30000 ohho@

Then in my MacBook's System Preferences > Network > Proxies

 (Enable) SOCKS Proxy
 SOCKS Proxy sever:
 Bypass proxy settings for these Hosts & Domains:
   *.local, 169.254/16,

Now I can surf the web, so far so good.

For development, I set up a few entries in /etc/hosts for virtual hosts purpose:

In bash:

 $ ping
 PING ( 56 data bytes
 64 bytes from icmp_seq=0 ttl=64 time=0.046 ms

 $ curl

It looks good and curl returns the content of the index.html nicely.

However, if I try to open the site: in the browsers (Safari/Chrome/Firefox), none of them returns the result like curl did. Chrome give an error:

This webpage is not available The webpage at might be temporarily down or it may have moved permanently to a new web address. Error 120 (net::ERR_SOCKS_CONNECTION_FAILED): Unknown error.

If I add another entry in /etc/hosts:

In bash:

 $ ping
 PING ( 56 data bytes
 64 bytes from icmp_seq=0 ttl=64 time=0.047 ms
 64 bytes from icmp_seq=1 ttl=64 time=0.128 ms
 --- ping statistics ---
 2 packets transmitted, 2 packets received, 0.0% packet loss
 round-trip min/avg/max/stddev = 0.047/0.087/0.128/0.041 ms

 $ curl

However, the browsers returns the content from the web server of the real Microsoft site, instead of the content from my MacBook (127.0.01). Why?


If I disable the SOCKS proxy, the browser returns the content from correctly.

If I disconnect the LAN cable, the browser returns the content from correctly.

share|improve this question
The information security officer in me needs to ask, Is there a reason your office doesn't provide public internet access, Mr. Snowden? ;) – 8None1 Jun 19 '13 at 16:22
What if you don't put in the bypass? Is is still localhost and shouldn't use the proxy anyway. Maybe it's the bypass function tripping up the browsers. – 8None1 Jun 19 '13 at 16:25

1 Answer 1

up vote 3 down vote accepted

Your browser is asking the SOCKS proxy for the sites, it is not connecting directly. Therefore putting the IP address in the exceptions list doesn't work, as your computer is not performing the look up of to The SOCKS proxy is.

To avoid this, place the full domain name of what you are accessing locally in the exceptions list in System Preferences > Network > Proxies.

So for you'd see an exception list (from your example above) of:

  *.local, 169.254/16,,

Your computer will now connect to directly, and therefore make use of /etc/hosts.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.