Why isn't my localhost resolved to 127.0.0.1

One of my application cannot work properly due to the localhost is unreachable. I tried to figure out what the problem is and I found out that the localhost is not 127.0.0.1.

The following is the output message when I run "dig localhost"


MarydeMacBook-Air:resolver feng$ ping localhost

PING localhost.local (202.102.110.203): 56 data bytes

Request timeout for icmp_seq 0

^C

--- localhost.local ping statistics ---

2 packets transmitted, 0 packets received, 100.0% packet loss

MarydeMacBook-Air:resolver feng$ dig localhost


; <<>> DiG 9.8.3-P1 <<>> localhost

;; global options: +cmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 53519

;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0


;; QUESTION SECTION:

;localhost. IN A


;; ANSWER SECTION:

localhost. 35 IN A 202.102.110.203


;; Query time: 9 msec

;; SERVER: 192.168.0.1#53(192.168.0.1)

;; WHEN: Wed Jul 1 07:55:37 2015

;; MSG SIZE rcvd: 43


The localhost is resolved to a foreign IP, 202.102.110.203, and the DNS server is 192.168.0.1 which is my wifi switch address.


The output of command "nslookup localhost" confirmed that:

MarydeMacBook-Air:resolver feng$ nslookup localhost

Server: 192.168.0.1

Address: 192.168.0.1#53


Non-authoritative answer:

Name: localhost.local

Address: 202.102.110.203


Does anyone knows what's the matter and how to resolve this problem?

Many thanks!

MacBook Air, OS X Yosemite (10.10.4)

Posted on Jun 30, 2015 5:00 PM

Reply
11 replies

Jul 1, 2015 8:09 AM in response to Linc Davis

MarydeMacBook-Air:resolver feng$ dig localhost


; <<>> DiG 9.8.3-P1 <<>> localhost

;; global options: +cmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 10061

;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0


;; QUESTION SECTION:

;localhost. IN A


;; ANSWER SECTION:

localhost. 35 IN A 202.102.110.203


;; Query time: 8 msec

;; SERVER: 192.168.0.1#53(192.168.0.1)

;; WHEN: Wed Jul 1 23:03:01 2015

;; MSG SIZE rcvd: 43

From the output message We can tell that localhost has been resolved by DNS server 192.168.0.1, which is the wireless router address. I checked the router setting and the DSN request will be transferred to ISP. So it seems that this problem is not related to any records in my /etc/hosts.

My hosts file is quite simple, there are three effective records:


127.0.0.1 localhost localhost.local

255.255.255.255 broadcasthost

::1 localhost

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Why isn't my localhost resolved to 127.0.0.1

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.