tags:

views:

68

answers:

3

I had MAMP installed (and working fine) then I tried to install mongoDB through macPorts. macports then began installing a bunch of dependencies. after that, http://localhost started giving an "It Works!" screen. after rebooting to see if it might fix it, I found that I could not start my MAMP server. console said this:

9/13/10 1:20:54 PM  [0x0-0x12012].de.appsolute.MAMP[133]    (48)Address already in use: make_sock: could not bind to address [::]:80

I know that macPorts did something stupid to mess with me. how can I find out what it installed thats stealing port:80?

here's some command I've tried: (:80 didn't work, so I just used 80)

$ sudo netstat -an | grep 80 
Password:
tcp46      0      0  *.80                   *.*                    LISTEN
udp6       0      0  fe80::21e:52ff:f.123   *.*                    
udp6       0      0  fe80::1%lo0.123        *.*   

and:

$ lsof -i :80
COMMAND   PID        USER   FD   TYPE     DEVICE SIZE/OFF NODE NAME
firefox-b 451 biting_duck   39u  IPv4 0x0ab806b0      0t0  TCP 192.168.0.198:49515->stackoverflow.com:http (ESTABLISHED)
firefox-b 451 biting_duck   40u  IPv4 0x0ab87ec8      0t0  TCP 192.168.0.198:49517->sstatic.net:http (ESTABLISHED)
firefox-b 451 biting_duck   41u  IPv4 0x0ab88aec      0t0  TCP 192.168.0.198:49516->pz-in-f95.1e100.net:http (ESTABLISHED)
firefox-b 451 biting_duck   42u  IPv4 0x0ab97334      0t0  TCP 192.168.0.198:49518->sstatic.net:http (ESTABLISHED)
firefox-b 451 biting_duck   47u  IPv4 0x0ab87abc      0t0  TCP 192.168.0.198:49519->sstatic.net:http (ESTABLISHED)
firefox-b 451 biting_duck   48u  IPv4 0x0ab886e0      0t0  TCP 192.168.0.198:49520->sstatic.net:http (ESTABLISHED)
firefox-b 451 biting_duck   50u  IPv4 0x0ab89b1c      0t0  TCP 192.168.0.198:49521->sstatic.net:http (ESTABLISHED)
firefox-b 451 biting_duck   51u  IPv4 0x0ab86680      0t0  TCP 192.168.0.198:49522->peak-colo-196-216.peak.org:http (ESTABLISHED)
firefox-b 451 biting_duck   54u  IPv4 0x0ab81ef8      0t0  TCP 192.168.0.198:49523->gravatar.com:http (ESTABLISHED)
firefox-b 451 biting_duck   55u  IPv4 0x0ab82710      0t0  TCP 192.168.0.198:49524->gravatar.com:http (ESTABLISHED)
firefox-b 451 biting_duck   56u  IPv4 0x0ab8a334      0t0  TCP 192.168.0.198:49526->64.34.80.176:http (ESTABLISHED)
firefox-b 451 biting_duck   57u  IPv4 0x0ab812d4      0t0  TCP 192.168.0.198:49525->pv-in-f101.1e100.net:http (ESTABLISHED)
A: 

The MongoDB port doesn't install anything that would require or use port 80. Nor does any of its dependencies. Furthermore, the only way a MacPorts port could grab port 80 on startup is if it installed a launch daemon, but MacPorts doesn't activate any launch daemons on its own (you have to do that manually).

However, you can find out what program is listening on a particular port by executing

$ lsof -i :<port>

For example,

$ lsof -i :80

will show you the program listening on port 80. That should narrow down what is grabbing the port.

mipadi
no dice. it just shows firefox, which I'm using to try and figure this out. :(I appended the code to my main question because the comment doesn't support code blocks
You need to `sudo` or lsof only shows files opened by your processes.
Gordon Davisson
A: 

apparently, macPorts or PECL installed another apache2 server. I went to /var/log/apache2/error_log and found that it was looking at /Library/Webserver. I renamed that to Webserver.bak and the console told me that /private/etc/apache2/httpd.conf couldn't find the directory. I renamed that to httpd.conf.bak and restarted. It (obviously) wasn't able to start the servers. this allowed me to start MAMP.

I noticed though, that it was still trying every 10 seconds:

9/13/10 3:00:50 PM  com.apple.launchd[1]    (org.apache.httpd) Throttling respawn: Will start in 10 seconds
9/13/10 3:01:00 PM  org.apache.httpd[800]   httpd: Could not open configuration file /private/etc/apache2/httpd.conf: No such file or directory
9/13/10 3:01:00 PM  com.apple.launchd[1]    (org.apache.httpd[800]) Exited with exit code: 1
9/13/10 3:01:00 PM  com.apple.launchd[1]    (org.apache.httpd) Throttling respawn: Will start in 10 seconds

so I renamed httpd.conf.bak and Websever.bak back to what they used to be and I got one more error message:

9/13/10 3:03:11 PM  org.apache.httpd[884]   (48)Address already in use: make_sock: could not bind to address [::]:80

Now its not running or trying to run. I still have no idea what it is that starts on startup that tries to start that apache2 server, but I figured out a workaround for now. If anybody knows how to remove/disable that new apache server, please let me know

MacPorts would look for config files under `/opt/local`. Seems like something else is the problem.
mipadi
I think your right. I actually aborted the MacPorts install because it had like 20 dependencies and was taking forever. I also tried using pecl. I honestly don't know where I messed up, but something installed another apache server on my computer. I changed the bad httpd to use port 81 so it doesn't interfere with my MAMP install, but I would like to remove it completely. I tried to stop it using apachectl stop, but it told me "httpd (no pid file) not running".
+1  A: 

From what you describe about launchd errors and /private/etc/apache2/httpd.conf, it sounds like the copy of Apache installed with the base OS got turned on. Check System Preferences -> Services -> Web Service, and turn it off if needed. If it's not turned on there, try:

sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist

...and if that doesn't work, take a look in /Library/LaunchDaemons to see if something else has been installed that's launching the system copy of Apache (/usr/sbin/httpd).

Gordon Davisson
You are 100% right! Something must have turned that on (I know I didn't). I feel so dumb now running around in circles only to find out it was that stupid checkbox in the System Preferences. Gordon Davisson, You Rock the kasbah!