Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have apache2 installed on Mac OS X 10.7.4 via macports

Recently I have not been able to access my localhost directory I get a 404, but I can access 127.0.0.1

I've tried restarting apache:

sudo /opt/local/apache2/bin/apachectl stop
sudo /opt/local/apache2/bin/apachectl start

and I get the following errors:

(48)Address already in use: make_sock: could not bind to address [::]:80
(48)Address already in use: make_sock: could not bind to address [::]:443

I've checked that web sharing is off. It seems like apache is already using these points or the service is not stopping correctly.

How can I find out what is using the ports?

share|improve this question

migrated from stackoverflow.com Sep 24 '12 at 22:17

This question came from our site for professional and enthusiast programmers.

up vote 1 down vote accepted

The "lsof" shell command can tell you exactly which process is using which files and socket addresses in the system. Just try a

sudo lsof

or, since the output will be a lot, better

sudo lsof | less

and look for something on the http ports. As usual

man lsof

will give you more information on how to customise the output.

share|improve this answer
    
Thanks lsof -i :80 shows processes using that port. Any idea how to fix the Apache errors? – benedict_w Sep 24 '12 at 9:23
    
Well, the only way to let Apache bind to those ports is by getting rid of the processes that are using them, try the 'kill' shell command... – Seg Fault Sep 24 '12 at 9:26
    
It seems that the mac version of apache has started /usr/sbin/httpd even though I have "web sharing" turned off. If I kill this process it restarts, even though it's disabled in the launch daemons. This seems to be what is stopping the macports apache running. – benedict_w Sep 24 '12 at 9:47

For reference, in Mountain Lion 10.8.2, simply stopping the apache2 service did the trick:

sudo apachectl stop

That way the httpd processes won't restart, and the Macports apache2 server will start fine after that.

share|improve this answer

You must log in to answer this question.

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