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

Apache via localhost / loopback not reachable from Safari or Firefox

I have apache running on my mbp and I access it using domains I have setup in my hosts file. I've been doing this for months and tonight, I unplugged my wired network and moved to wireless and the loopback/localhost is no longer reachable. I've searched and tried every suggestion I can find and nothing. All other network services work just fine, I just cannot access localhost using either firefox or safari.

From terminal, if I ping localhost I get a response. Cannot telnet to localhost.
From Safari/FF I can browse the entire net, just not the apache server running locally (arg!).

These do not work:
http://macbookpro.local
http://localhost
http://127.0.0.1
http://dev.mydomain.com (maps to 127.0.0.1 in hosts file)

I've disabled firewall, ipv6, restarted, put all configs back to where they were and all sorts of things to no avail. Weird thing is that I can't even get it back working when I plug back into the wired network either now.

Any suggestions of things to try? This has worked for a long time and all I did was unplug the wired connection to set it off, now I can't get back.

Any help is appreciated.

2010 MBP, Mac OS X (10.6.6)

Posted on Jan 21, 2011 8:39 PM

Reply
4 replies

Jan 22, 2011 5:26 AM in response to netslacker2000

I'm looking in two different directions with the following. Toward IP, and toward Apache.

This also assumes the firewall is currently off, and that this is Mac OS X client and not Mac OS X Server. (If you don't know which version you have, then you almost certainly have Mac OS X client. Server costs more. And it's not commonly encountered on MBP.)

Launch Terminal.app from the Utilities folder, and if you haven't already done this as part of your "put all configs back", then issue:

sudo mv /etc/hosts /etc/hosts_save


and create a new /etc/hosts with pico, vim or emacs or another command-level editor and containing the following:


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

dscacheutil -flushcache


try a reboot now, and then try the Safari connection again. (Yeah, you might be able to skip a step or two here, but I'm shot-gunning.)

If that connection fails, issue:

apachectl configtest


Depending on your Mac OS X version, you' get a spurious ulimit message +/usr/sbin/apachectl: line 82: ulimit: open files: cannot modify limit: Invalid argument+ (which can be ignored), and then a Syntax OK or one or more error diagnostics. If you get diagnostics (other than the ulimit), post those.

Then post the output from this:

sudo lsof -i -P | grep -i ":80"


Which will usually show what's connected to and listening on port 80.

I'm assuming you haven't been establishing static IP routes or other such. (What have you been changing here?)

Jan 22, 2011 6:52 AM in response to MrHoffman

Thanks, there was enough in there to try that once I completed the steps things started working again. I believe my problem lied in apache configs despite the fact I was convinced otherwise. Apache would start (hence running) but not accept incoming connections.

Now I'm inching forward again to try and get back where I was - cautiously.

Thanks again.

Apache via localhost / loopback not reachable from Safari or Firefox

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