How to turn off localhost web server

apachecupsSecurity

I've discovered by accident that my Mac is running a localhost web server. I typed "localhost" into Safari and got "It works!" I get the same result when I go to http://127.0.0.1:80.

My question is: How do I turn this thing off? I've tried things like this:

$ sudo apachectl stop

And

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

But this changes nothing, and the Terminal complains

/System/Library/LaunchDaemons/org.apache.httpd.plist: Could not find specified service

I'm running Catalina. No MAMP. I did at one point a couple of years ago run npm briefly, but there is no evidence that this is its server (for one thing, it's on port 80).


Following up on Gordon Davisson's suggestion, I tried

$ sudo lsof -i | grep LISTEN

and got:

rapportd   462  mattneubelcap    4u  IPv4 0x3fcd6c7f11a6984d      0t0    TCP *:49169 (LISTEN)
rapportd   462  mattneubelcap    5u  IPv6 0x3fcd6c7f0a82c41d      0t0    TCP *:49169 (LISTEN)
cupsd     1117           root    5u  IPv6 0x3fcd6c7f0a829f5d      0t0    TCP localhost:ipp (LISTEN)
cupsd     1117           root    6u  IPv4 0x3fcd6c7f1975f0cd      0t0    TCP localhost:ipp (LISTEN)

Best Answer

Hidden web server

The web server running on your server is the one used by cupsd to manage your printers queue.

The command:

nmap localhost -p 80

will show you that it is actually closed, unless you activated the sharing of a printer.

You can stop cupsd either through the GUI of System Preferences… or with launchctl:

/usr/bin/sudo launchctl unload /System/Library/LaunchDaemons/org.cups.cups-lpd.plist
/usr/bin/sudo launchctl unload /System/Library/LaunchDaemons/org.cups.cups.plist

Nmap

If you don't have nmap because your version of MacOS doesn't anymore bring this useful software (which is a total failure for people who need to analyse network problems) you can easily install it with Macports or Brew. I estimate uou will need 15 minutes to install it, read the basic documentation. Within less than half an hour you will be able to discover holes through which your system can be attacked.