How do I find out how macPorts stole my port:80?

末鹿安然 提交于 2019-11-30 15:45:22

问题


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)

回答1:


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




回答2:


On Max OS 10.1, Mountain Lion, turning off apache fixed this problem for me.

sudo apachectl stop



回答3:


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.




回答4:


Make sure your httpd.conf files are correct. This means: No more then 1 'Listen 80'. If you have Listen 80 (or whatever port) more then once, this will trigger the binding error.

I hope this is useful to you :)




回答5:


OS X had inbuilt apache webserver installed, which is located on /etc/apache2. The message ""It Works!" is displayed when somehow the apache webserver is started. Below are the process to stop/ start it.

sudo apachectl stop
sudo apachectl start

sudo is needed as webserver access port 80.




回答6:


If some service defines that it will listen to port 80, launchd will reserve it during the initial boot. It can be apache, but it can be something else as well. If you do not have apache, but have this problem try

cd ~/Library/LaunchAgents
grep -R 80 .
cd /System/Library/LaunchDaemons
grep -R 80 .

It should show you agents listening to port 80. Uninstall and restart!



来源:https://stackoverflow.com/questions/3703751/how-do-i-find-out-how-macports-stole-my-port80

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!