Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I ran across this question, but it wasn't resolved (and it hasn't been touched in a while). I'm not sure if my issue is the same, but I don't have enough reputation here to comment on that question.

I just upgraded from Snow Leopard (10.6.8) to Mavericks. Before the upgrade, I was able to visit http://localhost; but now I can't. I checked my hosts file, and it looked ok (but this isn't quite my area of expertise):

127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost 
fe80::1%lo0     localhost

I am still able to visit 127.0.0.1. This wouldn't necessarily be a huge deal, but I'm trying to use Sinatra on Thin which isn't working after the OS upgrade either (it was working on my Snow Leopard setup), so I fear there may be an underlying issue that could have other negative effects. Thanks.

share|improve this question
    
Not an exact answer to your problem but try muffintheman.localtest.me You can replace muffintheman with anything and it will resolve. We use this A LOT at work because we use subdomains for switching layouts and behavior. –  dstarh Oct 31 '13 at 21:25
    
@dstarh, that worked. Like you said, not really a fix for my problem; but it's interesting. I might look more into how that works. –  MuffinTheMan Nov 1 '13 at 1:04
    
I don't know if this is related. At a certain point (when I left Snow Leopard, perhaps) web sharing stopped working. So I got this small preference pane to bring it back: clickontyler.com/web-sharing –  GEdgar Nov 1 '13 at 18:25
    
@MuffinTheMan someone just registered the domain localtest.me and put a wildcard for *.localtest.me to point to 127.0.0.1 . We used to have to maintain large host files for specific clients and we've switched entirely to that domain now. –  dstarh Nov 4 '13 at 16:10
    
Interesting, @dstarh, thanks for the info! –  MuffinTheMan Nov 4 '13 at 19:34

3 Answers 3

up vote 3 down vote accepted

Everything seems to be working now. I can access localhost again, and my app is running Sinatra on Thin as it was before. Thanks to bmike, I did a bit of searching on why my loopback was unreachable and came across this article. I moved my old hosts file (/etc/hosts) to hosts.old and made a new one in its place that simply contained:

##
# 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

Then, I ran dscacheutil -flushcache and rebooted my computer*. After that, things appear to be working normally again. I can only guess that something weird happened with my old hosts file. I also took JakeGould's advice and blew away ruby 2.0.0 (I still had ruby 1.8.7--you cannot uninstall ruby entirely on a mac, since it uses ruby for other things) and rvm and reinstalled those; but I'm not sure that had anything to do with my success, as I still had the same issues until I followed the steps outlined above.

Note: the above hosts file contains virtually the same thing that I say my hosts file contained before (see original question); however, there were other things in my original hosts file that I did not share in my question (I just shared what I thought was the relevant part), so perhaps something there got borked when I upgraded--I wish I knew for sure.

*Rebooting is probably not necessary. I actually had this problem after setting up a new user from a backup drive on my machine at work (which is running Mountain Lion) and (just today) followed the same steps above (minus blowing away ruby and rebooting the machine), and it worked. This leads me to believe that the heart of the issue was a borked /etc/hosts file.

share|improve this answer

I have no such problems connecting to a web server when it's actually listening on port 80.

If you have no web server running, here is what you should get from terminal to show that name resolution is working on all network interfaces before the telnet gives up connecting to port 80:

mac:~ me$ telnet localhost 80
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
Trying fe80::1...
telnet: connect to address fe80::1: Connection refused
telnet: Unable to connect to remote host

Should you get different results, I would use scutil to determine reachability for your network destination:

mac:~ me$ scutil -r localhost
Reachable,Local Address
mac:~ me$ scutil -r loopback
Reachable
mac:~ me$ scutil -r 127.0.0.1
Reachable,Local Address

It might be worth checking if you have LittleSnitch or another firewall that has rules that are blocking network access or reboot into Safe mode to test if some kernel extensions or other conflict is preventing the default reachability and access to local ports. Also, you will most certainly want to check whatever web server you are running to ensure it's really listening to port 80:

mac:~ me$ sudo lsof -i :80 | egrep "PID|LISTEN"
Password:
COMMAND   PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
httpd    1645 root    8u  IPv6 0x513627eaa81c8205      0t0  TCP *:http (LISTEN)
httpd   15851 _www    8u  IPv6 0x513627eaa81c8205      0t0  TCP *:http (LISTEN)
httpd   72969 _www    8u  IPv6 0x513627eaa81c8205      0t0  TCP *:http (LISTEN)

Also, quit all web browsers or be prepared to filter those network connections from the above lsof command as it shows all connections over port 80.

share|improve this answer
    
telnet localhost 80 spits out localhost: nodename nor servname provided, or not known, but telnet 127.0.0.1 80 spits out Trying 127.0.0.1... \ Connected to localhost. \ Escape character is '^]'. What does that tell me? –  MuffinTheMan Nov 1 '13 at 1:08
    
@MuffinTheMan I've edited the answer substantially. Hopefully it now covers most of the bases... –  bmike Nov 1 '13 at 2:23
    
Thanks, @bmike. Results of scutil: localhost -> Reachable,Local Address - loopback -> Not Reachable - 127.0.0.1 -> Reachable,Local Address. So it looks like there's an issue with the loopback? –  MuffinTheMan Nov 1 '13 at 15:33

Mavericks (OS X 10.9) uses Ruby 2.0. Not clear on what you were using under Snow Leopard (OS X 10.6.8) but perhaps a major change in version broke something? In my experience Ruby upgrades are never easily backwards compatible and—IMHO—very frustrating to maintain from a system administrator’s point of view for reasons like this.

I would recommend reinstalling whatever Ruby gems you have in place & try again.

share|improve this answer
    
I'm using ruby 2.0.0p247 (and was before), but I don't think that should affect the localhost thing. –  MuffinTheMan Nov 1 '13 at 1:06
    
If you installed Ruby 2.0.0p247 manually on OS X 10.6.8 & then 10.9 installs it’s own version of 10.9, chances are high that it overwrote some gems or components in a way that would bork your setup. I recommend you simply reinstall the gems you need manually & see what happens. –  JakeGould Nov 1 '13 at 1:20
    
Thanks, I tried blowing away Ruby 2.0.0 and even rvm--then reinstalled. No change :/ –  MuffinTheMan Nov 1 '13 at 15:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.