Can't connect to port 80 on localhost
FINALLY figured it out. I had installed Pow (http://pow.cx). It runs this script: http://get.pow.cx. The script installs some firewall rules. Even though I had disabled pow, the firewall rules were still in place. Running the pow uninstall script fixed it.
I have several suggestions. First, check to make sure the packet filter firewall is off. Here's an example on my Mac, with the firewalls off:
$ sysctl net.inet.ip.fw.enable
net.inet.ip.fw.enable: 1
$ sudo ipfw show
Password:
65535 0 0 allow ip from any to any
The sysctl command shows the firewall is actually enabled, but the second shows that its rules allow all traffic. The symptoms aren't consistent with the application firewall, but check it anyway just to be sure:
$ defaults read /Library/Preferences/com.apple.alf globalstate
0
Here 0 means off, 1 means on, and 2 means "Block all incoming connections" mode. If neither of those shows an active firewall, the next things I'd do is run tcpdump to see what's going on between telnet and nc. Here's a successful connection:
$ sudo tcpdump -ilo0 port 80
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on lo0, link-type NULL (BSD loopback), capture size 65535 bytes
20:35:28.193217 IP localhost.49531 > localhost.http: Flags [S], seq 1937962870, win 65535, options [mss 16344,nop,wscale 3,nop,nop,TS val 7494959 ecr 0,sackOK,eol], length 0
20:35:28.193286 IP localhost.http > localhost.49531: Flags [S.], seq 1740947472, ack 1937962871, win 65535, options [mss 16344,nop,wscale 3,nop,nop,TS val 7494959 ecr 7494959,sackOK,eol], length 0
20:35:28.193298 IP localhost.49531 > localhost.http: Flags [.], ack 1, win 65535, options [nop,nop,TS val 7494959 ecr 7494959], length 0
20:35:28.193307 IP localhost.http > localhost.49531: Flags [.], ack 1, win 65535, options [nop,nop,TS val 7494959 ecr 7494959], length 0
This obviously won't solve the problem, but might give a good clue what's going on.
Without nc listening, does netstat -an
show anything listening to tcp on port 80?
Do you have "Web Sharing" enabled under System Preferences -> Sharing? That runs Apache...