Fixed localhost lookup for some scenarios