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 fire up sudo nc -l 127.0.0.1 80. There's no errors. I then try telnet 127.0.0.1 80. It won't connect.

Same thing with port 81 works fine.

As far as I know, there's no firewalls running.

https://img.skitch.com/20120228-t8h98sccsde3w1jnf2tb55xdny.png shows the commands I'm using. (the numbers are the order in which the commands are run)

I'm on OS X 10.7.3.

share|improve this question
add comment

4 Answers

up vote 3 down vote accepted

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.

share|improve this answer
    
Me too. And I had manually unloaded the pow firewall launchd item already. :'( –  indirect Feb 15 '13 at 0:28
add comment

I've had this problem before, with an older version of Skype, that also uses port 80. To start Apache, i had to stop Skype, start Apache, then restart Skype. Seems to be fine in more recent versions though.

share|improve this answer
add comment

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.

share|improve this answer
add comment

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

share|improve this answer
    
No, Apache isn't running. If something else were running on port 80, telling nc to listen on that port would fail. netstat shows nothing running on port 80. –  Joe Van Dyk Feb 28 '12 at 1:17
add comment

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.