No idea what is listening on port 80 in OS X

You need to run these commands as root to show other users' processes, for example:

sudo lsof -i ':80'

Mac OS X includes an Apache web server that can be controlled using apachectl as root. It's usually started via launchd, the corresponding configuration file is /System/Library/LaunchAgents/org.apache.httpd.plist. If it's not this Apache running on port 80, it is probably launchd, Apple's implementation of a daemon manager. According to Wikipedia:

When launchd scans through the job plists at boot time it reserves and listens on all of the ports requested by those jobs. If so indicated in the plist by the "OnDemand" key, the daemon is not actually loaded at the time. Rather, launchd will listen on the port, start the daemon when needed, and shut it down when it is not. After a daemon is loaded, launchd will keep track of it and make sure it is running if needed.


Just to make the actual answer clear in case users are searching for this.

  1. launchd scans the /System/Library/LaunchDaemons/ on boot and works out from org.apache.httpd.plist that it when apache is started it needs to forward port 80 onto it.

  2. sudo apachectl start was done

  3. However there was a mistake in the httpd.conf file meaning apache was not started, although this was not reported via the apachectl command.

  4. Launchd decided to listen on port 80 as it thought apache was up.

  5. But the contents of any HTTP request resulted in an immediate close of the connection.

  6. sudo lsof -i :80 yielded no answers

  7. sudo netstat -an | grep LISTEN yielded no answers for port 80

  8. there was no information so far as I could tell in any diagnostic tools that showed that port 80 was in-use or listening.

  9. fixing apache's httpd.conf and restarting apache successfully so httpd was in the ps table, led HTTP requests to be successful.

  10. I was therefore mistaking that I couldn't run apache because there was already something listening on port 80, rather than apache conf itself was the cause