More robust localhost lookup