Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Cannot ping localhost anymore

I have setup a new MacBook Pro retina, things were going well but now I cannot access localhost.


$ ping localhost
ping: cannot resolve localhost: Unknown host


My /etc/hosts file is fine, or at least untouched.


I have tried flushing the DNS cache, and `dig localhost` spits out


; <<>> DiG 9.8.3-P1 <<>> localhost
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 50562
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;localhost.         IN  A

;; AUTHORITY SECTION:
.           1551    IN  SOA a.root-servers.net. nstld.verisign-grs.com. 2013030800 1800 900 604800 86400

;; Query time: 31 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Fri Mar  8 14:53:09 2013
;; MSG SIZE  rcvd: 102


I am at a loss what to try next! I have even run OnyX to clean all cache etc...

MacBook Pro with Retina display, OS X Mountain Lion (10.8.2)

Posted on Mar 8, 2013 8:59 AM

Reply
19 replies

May 16, 2013 6:09 AM in response to etresoft

OK, I have the same problem. I was installing "unusual" software for a macbook - a full ERP system that includes web portals for field personnel. Everything was going along hunky dory (relatively) till, in launching the web portal, I recieved an error that seemed to be a users permission issue:


User uploaded file

I had no .rhosts file, so I created one with the suggested information in the top directlry for my user (/users/dons/). This not only did not work but the local apache website no longer displayed:


User uploaded file


Here are my ping attempts, first by name:


Last login: Wed May 15 21:37:32 on ttys000

Donalds-MacBook-Air:~ dons$ ping localhost

ping: cannot resolve localhost: Unknown host

Donalds-MacBook-Air:~ dons$


Here's the ping by ip:


Donalds-MacBook-Air:~ dons$ ping 127.0.0.1

PING 127.0.0.1 (127.0.0.1): 56 data bytes

64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.053 ms

64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.171 ms

64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.126 ms

64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.182 ms

^C

--- 127.0.0.1 ping statistics ---

4 packets transmitted, 4 packets received, 0.0% packet loss

round-trip min/avg/max/stddev = 0.053/0.133/0.182/0.051 ms

Donalds-MacBook-Air:~ dons$


Here's my hosts file:


User uploaded file


At this point I have:

  • Removed the .rhosts file
  • Restored the hosts.equiv to blank
  • Performed a safe boot - same problem
  • Reinstalled OS X - same problem.


The major programs I've installed are Java 7, Eclipse, Perforce. This might not be anything, but on startup I get a terminal screen that shows the following:


Donalds-MacBook-Air:etc dons$ /System/Library/Frameworks/JavaVM.framework/Versions/A/Commands/java

Usage: java [-options] class [args...]

(to execute a class)

or java [-options] -jar jarfile [args...]

(to execute a jar file)

where options include:

-d32 use a 32-bit data model if available

-d64 use a 64-bit data model if available

-server to select the "server" VM

The default VM is server,

because you are running on a server-class machine.

-cp <class search path of directories and zip/jar files>

-classpath <class search path of directories and zip/jar files>

A : separated list of directories, JAR archives,

and ZIP archives to search for class files.

-D<name>=<value>

set a system property

-verbose:[class|gc|jni]

enable verbose output

-version print product version and exit

-version:<value>

require the specified version to run

-showversion print product version and continue

-jre-restrict-search | -no-jre-restrict-search

include/exclude user private JREs in the version search

-? -help print this help message

-X print help on non-standard options

-ea[:<packagename>...|:<classname>]

-enableassertions[:<packagename>...|:<classname>]

enable assertions with specified granularity

-da[:<packagename>...|:<classname>]

-disableassertions[:<packagename>...|:<classname>]

disable assertions with specified granularity

-esa | -enablesystemassertions

enable system assertions

-dsa | -disablesystemassertions

disable system assertions

-agentlib:<libname>[=<options>]

load native agent library <libname>, e.g. -agentlib:hprof

see also, -agentlib:jdwp=help and -agentlib:hprof=help

-agentpath:<pathname>[=<options>]

load native agent library by full pathname

-javaagent:<jarpath>[=<options>]

load Java programming language agent, see java.lang.instrument

-splash:<imagepath>

show splash screen with specified image

See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.


As I said at this point, I've already reinstalled the operating system. The above error points me to a java problem (that and I no longer have a java icon on my system preferences), so I'm going to reinstall that first. If that doesn't work, I'm guess I'm going to have to erase the disk and go back to a factory reinstall.


Any helpful thoughts, directions or words of encouragement will be greatly appreciate.


Don Scattergood

May 16, 2013 7:05 AM in response to TheDonOfLGI

.rhosts? That stuff is ancient. I suggest you start your own question instead of piggy-backing on this one. I don't think you need to reinstall anything. You just need to track down instructions on how to undo a couple of decades of good security practices.


Figure out exactly how this software is supposed to work. Figure out how to get .rhosts working on your Mac. (Here is are tips: https://discussions.apple.com/thread/4652712?start=0&tstart=0). Good luck with that enterprise software. You'll need it! (The luck, not the enterprise software, that is).

May 16, 2013 7:20 AM in response to etresoft

Thanks, I did post it in a new question.


At this point my problem is not specifically with the new software - I've uninstalled that. I'm taking baby steps just trying to get the system to resolve localhost. I can't ping it, and I can't browse to it, although the associated ip address works in both systems. Somehow the DNS portion of this machine is not associating 127.0.0.1 with localhost. Once I've gotten that resolved, everything else can be corrected.


There's got to be some place within OS X that manages domain name resolution other than the hosts file.


Any ideas?

Cannot ping localhost anymore

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