Score:0

Apache on OSX: "not running" and "already in use" for all processes?

de flag
pop

OS: macOS Mojave 10.14.6
HTTP Server: Apache 2.4.55

When trying to restart apache server, I get "Address already in use..." message. Hm, so there must be a process that listens to that port, right? With this line (from elsewhere) in Terminal to see what's up:

ps auxw | grep  httpd

it gives

_www              1317   0.0  0.1  4361716   7452   ??  S    12:39AM   0:00.10 /usr/sbin/httpd -D FOREGROUND
_www              1303   0.0  0.1  4361716   7364   ??  S    12:39AM   0:00.23 /usr/sbin/httpd -D FOREGROUND
root               104   0.0  0.1  4359628   5956   ??  Ss   12:20AM   0:01.07 /usr/sbin/httpd -D FOREGROUND
ausername         7671   0.0  0.0  4277256    804 s003  S+   12:21PM   0:00.00 grep httpd
_www              7654   0.0  0.0  4359604   1004   ??  S    12:21PM   0:00.00 /usr/sbin/httpd -D FOREGROUND

Right, so now I try to stop it

httpd -k stop

which gives

httpd (no pid file) not running

Ok, then I try with

/usr/sbin/httpd -k stop
httpd (pid 104?) not running

Hm... maybe:

apachectl -k stop
httpd (no pid file) not running

So what is running then? And how do I restart it? This is the first time I'm dealing with this kind of errors regarding Apache on OSX.

I've checked this thread but nothing worked for me. Using grep -ri listen /etc/apache2 I've got a list of multiple Listen: 80 however all of them where in httpd.conf files with .bak, .original, ~previous, .pre-update. All except for one being used for httpd. How do I know? httpd -V which gives:

-D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=256
 -D HTTPD_ROOT="/opt/local"
 -D SUEXEC_BIN="/opt/local/bin/suexec"
 -D DEFAULT_PIDLOG="var/run/apache2/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="etc/apache2/mime.types"
 -D SERVER_CONFIG_FILE="etc/apache2/httpd.conf"

and that last file has these lines:

Listen 8080
Listen 80

So now I am out of ideas.

PS: After digging in the logs, this now is a telling sign that I have multiple Apache installations (probably leftovers from Homebrew installations). These two lines:

[Fri Feb 17 00:22:56.067511 2023] [mpm_prefork:notice] [pid 104] AH00163: Apache/2.4.46 (Unix) PHP/7.3.33 LibreSSL/2.5.5 configured -- resuming normal operations
[Fri Feb 17 00:22:56.067613 2023] [core:notice] [pid 104] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'

First line says it is running Apache/2.4.46 but it is not the version I get when I run httpd -v The second line seems to log the starting command for the Apache process. Where could this command line possibly be located? Has to do with startup process, right?

ph flag
Try `type -a httpd` to get a list of the apache binaries in your `PATH` (which isn't necessarily all of them, but it's a start). Also, it might be launchd running the system version of apache; see my answer [here](https://stackoverflow.com/questions/39309814/killing-an-unknown-self-restarting-server-on-port-80-mac-osx).
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.