3

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)
4
  • 1
    What version of macOS are you running? Do you have any MAMP or MAMP PRO type of packages installed? Commented Jul 4, 2020 at 19:22
  • Hi @user3439894, thanks, I've added that info at the end of the question.
    – matt
    Commented Jul 4, 2020 at 20:18
  • 1
    Find the process IDs of the web server with sudo lsof -i :80 | grep LISTEN, then try searching the active launch daemons for the master process's PID with sudo launchctl list | grep <masterPID>. See this Q&A for an example. Commented Jul 4, 2020 at 20:44
  • @GordonDavisson No result on that lsof, unfortunately.
    – matt
    Commented Jul 4, 2020 at 21:17

1 Answer 1

2

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.

1
  • That's correct. There's no nmap, and System Preferences > Sharing didn't help, but System Preferences > Printers and Scanners revealed that the checkbox to share this printer was checked for my printer. Unchecking the checkbox turned off the server. Now I've turned printer sharing back on but the web server has not reappeared. At least if it does I'll know what it is! Thanks.
    – matt
    Commented Jul 4, 2020 at 22:39

You must log in to answer this question.

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