2

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.

4 Answers 4

4

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.

1
  • Me too. And I had manually unloaded the pow firewall launchd item already. :'(
    – indirect
    Commented Feb 15, 2013 at 0:28
3

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.

1

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

1
  • 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. Commented Feb 28, 2012 at 1:17
0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .