13 Replies Latest reply: Feb 19, 2014 9:39 AM by PixelyP3la
andres.hume Level 1 Level 1

I'm using a Mac Book Pro running Mountain Lion 10.8.2.

 

Using Xcode I tried to test my app and found an alert box saying a string 'localhost' was not found. Tried to ping localhost and found that the DNS can't resolve this domain. I don't know if it's related but since a few weeks ago I can't use network printers hosted on Windows computers. OS X sees the workgroup and list computers but when I try to connect it throws an error telling the IP is wrong or the connection is lost.

 

Even stranger is the fact that ping can resolve localhost. (with the dot at the end).

 

Any help with either of this two issues??


OS X Mountain Lion (10.8.2)
Solved by Linc Davis on Oct 22, 2012 12:08 PM Solved
That's your problem. It should be just ASCII English text. Use an editor such as TextWrangler or BBEdit to clean it up.
  • Linc Davis Level 10 Level 10
    expertise.desktops
    Desktops

    Check the hosts file (/etc/hosts). It should begin with this:

     

    ##

    # Host Database

    #

    # localhost is used to configure the loopback interface

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

    ##

    127.0.0.1                              localhost

    255.255.255.255          broadcasthost

    ::1                                        localhost

    fe80::1%lo0                    localhost

  • andres.hume Level 1 Level 1

    yeap! First of all, thanks for your reply!

     

    It looks just like that but I still have the same problem. Even worse, I've just added a line to the hosts file and it seems like de OS is overriding the changes. For exmaple, I added this line:

    190.211.1.1 intranet.somecompany.com.ar

     

    and when I ping this domain....it says it can't be resolved.

    Any other clue? I hope there is another way to solve this than having to make a clean installation.

     

    Best regards!

    Andres (Andrew)

  • Linc Davis Level 10 Level 10
    expertise.desktops
    Desktops

    Please post the contents of the hosts file and the output of "ls -Oel /etc/hosts".

  • andres.hume Level 1 Level 1

    Sure! here it goes!

    The output is:

    -rw-rw-rw-@ 1 andreshume  staff  - 2011 Oct 17 16:58 /etc/hosts

    0: group:admin allow read,write,append,readattr,writeattr,readextattr,writeextattr,readsecurity

     

    And the contents of the hosts file are:

     

    ##

    # Host Database

    #

    # localhost is used to configure the loopback interface

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

    ##

    127.0.0.1          localhost

    255.255.255.255          broadcasthost

    ::1             localhost

    fe80::1%lo0          localhost

    # APURAR LOS HOSTS

    190.210.142.NN intranet.mycompany.com.ar

     

    I've changed the IP address and the "mycompany" just to preserve this info. If you really need it, I will post it.

     

    Thx again!

    Andrés

  • Linc Davis Level 10 Level 10
    expertise.desktops
    Desktops

    Repair the permissions of the startup volume in Disk Utility, and see whether there's any change.

  • andres.hume Level 1 Level 1

    Still got the same problem. It can't resolve localhost but when I ping localhost. it's ok.

    Now it can't even find server.local I have tu use the IP address.

     

    One more chance?

  • Linc Davis Level 10 Level 10
    expertise.desktops
    Desktops

    Post the output of

     

    file -b /etc/hosts

  • andres.hume Level 1 Level 1

    ASCII English text, with CR line terminators

  • Linc Davis Level 10 Level 10
    expertise.desktops
    Desktops

    That's your problem. It should be just ASCII English text. Use an editor such as TextWrangler or BBEdit to clean it up.

  • andres.hume Level 1 Level 1

    All right, got the editor but just can't figure out how to do this. I'm sorry. Any guide?

  • andres.hume Level 1 Level 1

    Done!!! the problem is solved. Thanks a lot Linc Davis! you really rock!

  • PixelyP3la Level 1 Level 1

    I am facing the same problem. The output for "file -b /etc/hosts" is "ASCII text".

    I really don't know how to change or clean it. The content in the file host is really simple, just numbers, dots and #.

    For me, works when I use 127.0.0.1 and "localhost." but "localhost" without the dot doesn't work. Please help me, it is driving me crazy!

  • PixelyP3la Level 1 Level 1

    Got it! the starting lines were missing.