Killing an unknown self restarting server on port 80 Mac OSX
Asked Answered
R

4

16

I have a server running on port 80, but I do not know what it is or where it came from. When I run

sudo lsof -i :80 | grep LISTEN

I get

httpd      80    root    5u  IPv6 0x91f5a9de62859cfd      0t0  TCP *:http (LISTEN)
httpd     694    _www    5u  IPv6 0x91f5a9de62859cfd      0t0  TCP *:http (LISTEN)

I have tried to enter get the process name using the PID, but all I ever get in return is "httpd" or "FOREGROUND".

When I kill the PID, the process simply restarts with a new PID. I assume I will have to stop it at launch.

How can I stop this server from running at startup?

If it helps any, I am trying to free up port 80 to use the apache server on MAMP.

Randolf answered 3/9, 2016 at 17:55 Comment(3)
What do you get if you open http://localhost in your browser (on the same machine of course)?Tawannatawdry
oddly enough, I get a page that says in <h1> "It works!"Randolf
I must have installed a server a long time ago on port 80, with a test file confirming that everything was working. But I don't remember anything; if only I knew how to figure out which server this isRandolf
L
28

This is just a guess, but it might be the built-in version of apache, being launched (& restarted) by launchd (OS X's daemon manager). It's disabled by default, but might've gotten enabled somehow. You can try disabling it with:

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

If that doesn't do it (it'll say something like "Could not find specified service"), you can check to see if it's some other launch daemon item by looking for the PID of the master process (the one running as root, not _www):

sudo launchctl list | grep <masterPID>

That won't necessarily tell you exactly what's going on, but might point you in the right direction.

Louque answered 3/9, 2016 at 21:20 Comment(4)
Thank you for all the information! It is truly helpful, for now I will simply stop the "apachectl" process. But I will definitely be looking into the more technical aspects as I get more time on my handRandolf
I've been struggling with an unkillable service on port 80. Nothing I did would stop it, however your first solution worked. Does this have any negative effects though?Pupillary
@KevinF. Unless something was using that service (unlikely), it should be perfectly safe to turn it off.Louque
This was it for me! Thank you!!Sandoval
L
8

Like Gordon suggested, that's the built-in version of the Apache web server.

You can stop it with

sudo apachectl stop

btw, the configuration for this webserver can be found in the /etc/apache2/httpd.conf directory.

Labiate answered 4/9, 2016 at 12:2 Comment(1)
thank you so much, I'm not sure why, but whenever I tried "apachectl stop" when I wasn't logged in as root, it never worked(even with the "sudo" preference". Now everything is just right!Randolf
C
1

This happens to me a lot. As @Gordon Davisson explains it is most likely the launchdeamon process conflicting with the service you have set up. Definitely stop the apachetl server.

sudo apachetl -k stop

Try to find all the httpd process, they should be the last ones

sudo lsof -i :80 // without grep

Then get the first process (most likely in the 1000s) should also be the lowest one.

sudo kill <firstHttpdPID>

This should kill ALL the processes running that httpd instance and then you get simply start back up your server. Must stop it first though or it will continue running again.

Cotquean answered 11/4, 2018 at 4:41 Comment(0)
S
1

Mac OSX comes bundled with Apache, however it is deactivated. You might have activated it somehow. In my case, I have previously install XAMPP and configured something in the /etc/apache2/httpd.conf that leads my port localhost:80 to leads to html page with It Works!.

TLDR, the solution is to deactivate the Apache2 server. Go to your terminal, and type this

sudo apachetl -k stop

In my case, it returns the following:

AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using Shafies-MacBook-Pro.local. Set the 'ServerName' directive globally to suppress this message
httpd (no pid file) not running

if you typed localhost on your browser, the port 80 is not active anymore and you will not see It Works! anymore.

For context, I have deleted XAMPP long time ago and not aware that my localhost:80 is still active. I am not able redirect dummy domain -- posts.com to my localhost port for my kubernetes YAML config files.

This is my ingress-srv.yaml file:

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: ingress-srv
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/use-regex: 'true'
spec:
  rules:
    - host: posts.com
      http:
        paths:
          - path: /?(.*)
            backend:
              serviceName: client-srv
              servicePort: 3000

and I have tricked the operating system to redirect my posts.com to localhost:80 by adding below line in the hosts file located at /etc/hosts

127.0.0.1 posts.com

by SM

Stripy answered 10/8, 2020 at 1:27 Comment(1)
sudo apachetl -k stop <-- typo sudo apachectl -k stopRichmound

© 2022 - 2024 — McMap. All rights reserved.