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

Mar 8, 2013 10:42 AM in response to alexperetti

Please read this whole message before doing anything.

This procedure is a diagnostic test. It’s unlikely to solve your problem. Don’t be disappointed when you find that nothing has changed after you complete it.
The purpose of the test is to determine whether the problem is caused by third-party software that loads automatically at startup or login.


Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards. Boot in safe mode* and log in to the account with the problem. The instructions provided by Apple are as follows:

  • Shut down your computer, wait 30 seconds, and then hold down the shift key while pressing the power button.
  • When you see the gray Apple logo, release the shift key.
  • If you are prompted to log in, type your password, and then hold down the shift key again as you click Log in.
*Note: If FileVault is enabled under OS X 10.7 or later, or if a firmware password is set, or if the boot volume is a software RAID, you can’t boot in safe mode.


Safe mode is much slower to boot and run than normal, and some things won’t work at all, including wireless networking on certain Macs. The next normal boot may also be somewhat slow.
The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.


Test while in safe mode. Same problem?


After testing, reboot as usual (i.e., not in safe mode) and verify that you still have the problem. Post the results of the test.

Mar 8, 2013 1:24 PM in response to alexperetti

Back up all data.


Boot into Recovery by holding down the key combination command-R at the startup chime. Release the keys when you see a gray screen with a spinning dial.


Note: You need an always-on Ethernet or Wi-Fi connection to the Internet to use Recovery. It won’t work with USB or PPPoE modems, or with proxy servers, or with networks that require a certificate for authentication.


When the OS X Utilities screen appears, follow the prompts to reinstall the OS. You don't need to erase the boot volume, and you won't need your backup unless something goes wrong. If your Mac was upgraded from an older version of OS X, you’ll need the Apple ID and password you used to upgrade, so make a note of those before you begin.

Mar 8, 2013 4:43 PM in response to alexperetti

alexperetti wrote:


I used homebrew to install a few things like coffeescript, sass etc...

Which has always been fine before.


And I am guessing booting in Safe Mode would get around that?

Can you explain exactly what the "etc" package does?


Basically you have installed any number of open-source software packages from Linux and done some level of low-level system modification. Perhaps you don't even know all the changes you made.


Safe boot will get around 3rd party software that has been installed on top of OS X. It won't help if you have actually modified the operating system. That looks like what is going on here.


While a complete reinstall is probably a good idea, it would be nice to have a full list of all system modifications. That way, when this happens again, we can help you fix the problem without reinstalling the OS.

Mar 8, 2013 5:20 PM in response to etresoft

Everything I have installed I have installed on other machines before with no issue.

I guess I must have messed up somewhere but it would be hard to trace back.


I am going to unistall homebrew and everything setup there, if that doesn't fix things do an OS reinstall.

I will make sure to document every step in case there is an issue.


The pacakges I have installed on homebrew in themselves are standard

brew-gem

git

mysql

node


Then I installed coffeescript/sass using node.

Mar 8, 2013 6:08 PM in response to alexperetti

None of that should affect localhost resolution. However, this seems representative of a trend I am noticing with Linux people switching to OS X. They tend to use tools and practice that would be familiar to Linux users. I think this is important to recognize because you may have made a change that you think is completely normal and "standard". It may be on Linux but not here. OS X isn't Linux. OS X isn't BSD either. It has many familiar interfaces but it also typically has another level of Appleisms that you don't know about.


There is technically nothing wrong with anything you have listed. But then again, localhost typically doesn't stop working. There is no standard package manager for OS X. Homebrew seems to be surpassing the popularity of MacPorts which, in turn, surpassed Fink. But very little of that open source software was designed for the Mac. At best, it was hacked up in 2006 and, once running, never touched again. MySQL is an excellent example. It is as stable as they come but its startup scripts haven't been updated in 7 years. All of this software is written by people who simply don't know the Mac and, quite frankly, don't care to either.


I suggest starting over and reinstalling OS X. You are obviously doing development so install Xcode. That includes git and lots more stuff. Follow my user tips to setup a local web server, mail server, and MySQL server. Install node directly. Be very, very reluctant to use "sudo" or enter your admin password.

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.