Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have trouble with name resolution when using programs like gem in my shell within my office environment.

Whenever a program needs to connect to a remote host, it fails to resolve the domain name, but after a "manual resolution" e.g. via dig or ping the same command will succeed.

Basically, this is what I have to do now:

$ gem install guard-sass
ERROR:  Could not find a valid gem 'guard-sass' (>= 0), here is why:
          Unable to download data from - no such name (
ERROR:  Possible alternatives: guard-sass
$ ping
PING ( 56 data bytes
Request timeout for icmp_seq 0
--- ping statistics ---
3 packets transmitted, 0 packets received, 100.0% packet loss
$ gem install guard-sass
Fetching: guard-sass-1.3.2.gem (100%)
Successfully installed guard-sass-1.3.2
Parsing documentation for guard-sass-1.3.2
Installing ri documentation for guard-sass-1.3.2
1 gem installed

This problem is not specific to one command or programming language, but rather occurs on any of the following:

  • gem - Uses ruby under the hood
  • composer - Uses php
  • vagrant - Uses ruby
  • brew - Uses ruby
  • git - Uses C


  • Mac OS X 10.9 (Had the same issue on 10.8 as well)
  • zsh

It does not affect any browsers or other applications with a GUI.

The problem doesn't occur in other environments (e.g. at home) with the same machine.

Any idea on how to troubleshoot this kind of problem?

Follow up:

  • I get both IP address and DNS server address via DHCP both at the office and at home.
  • I also tried using an external DNS server like Google's
  • The Mac only goes to sleep while transferring between office and home (no full reboot).
  • I tried both using the same shell and opening a new session when experiencing this issue at the office. Also tried a full restart of the computer and flushing DNS cache (dscacheutil -flushcache;sudo killall -HUP mDNSResponder).
share|improve this question
May this question be better suited for superuser? I can't tell (it is, after all, a problem with a office environment) but can transfer it, if requested. – Felix Nov 20 '13 at 12:42
What are your connection settings? Are you using DHCP? If so, are you using DHCP to get the DNS servers or are they set static while DHCP only sets the IP address? Are you powering down the machine to move it from home to work, or simply sleeping it? (I'm assuming it's a laptop of some sort.) Are you opening a new shell after switching environments, or is the shell persistent between environments? – John Nov 20 '13 at 13:44
Thanks for your response, John. I've edited my post to include the additional information requested. – Felix Nov 20 '13 at 15:22

Your Answer


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

Browse other questions tagged or ask your own question.