Previous 1 2 Next 19 Replies Latest reply: May 16, 2013 8:03 AM by etresoft
alexperetti Level 1 Level 1 (0 points)

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

;localhost.         IN  A

.           1551    IN  SOA 2013030800 1800 900 604800 86400

;; Query time: 31 msec
;; 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)
  • Linc Davis Level 10 Level 10 (159,235 points)

    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.

  • alexperetti Level 1 Level 1 (0 points)

    Thanks that was a good idea.


    The problem seems to persist in safe mode.

    Still hitting unknown host.

  • Linc Davis Level 10 Level 10 (159,235 points)

    Post the complete contents of the hosts file.

  • BobHarris Level 6 Level 6 (15,385 points)

    By any chance did you enable System Preferences -> Security -> Firewall -> Advanced -> [X] Enable stealth mode ?

  • Linc Davis Level 10 Level 10 (159,235 points)

    Good thought, but that would cause the pings to time out. It wouldn't cause "localhost not found."

  • alexperetti Level 1 Level 1 (0 points)

    Firewall isn't setup


    and /etc/hosts has



    # Host Databases


    # localhost is used to configure the loopback interface

    # when the system is booting.  Do not change this entry.

    ##                    localhost          broadcasthost

    ::1             localhost

    fe80::1%lo0                    localhost


    All pretty standard

  • Linc Davis Level 10 Level 10 (159,235 points)

    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.

  • etresoft Level 7 Level 7 (26,600 points)

    alexperetti wrote:


    things were going well but now I cannot access localhost.

    And what things were those?

  • Frank Caggiano Level 7 Level 7 (25,715 points)

    What does

    # dscacheutil -q host -a ip_address



    HAve you looked at Cannot resolve localhost

  • alexperetti Level 1 Level 1 (0 points)

    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?

  • alexperetti Level 1 Level 1 (0 points)

    I looked at that thread but it didn't help me, the command spits out:

    name: localhost




    Which is normal, looks like re-installing the OS is the only way.... urgh

  • etresoft Level 7 Level 7 (26,600 points)

    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.

  • alexperetti Level 1 Level 1 (0 points)

    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






    Then I installed coffeescript/sass using node.

  • etresoft Level 7 Level 7 (26,600 points)

    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.

Previous 1 2 Next