I have a problem with Apache on Mac OS Big Sur. After the OS update, the Apache (using Brew) doesn’t work anymore.
So I have decided to uninstalled the httpd
Formula.
Then tested is the preinstalled version of Apache works and it does.
- So I have stopped the preinstalled Apache
sudo apachectl stop
- Unloaded launcher
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null
- Updated the Homebrew
brew update
brew doctor
brew upgrade
- Installed the httpd again
brew install httpd
(installed successfully) - Started the httpd
sudo brew services start httpd
However checking the status sudo brew services list
I can see that the httpd service has status error
.
When I try to start apache using sudo apachectl start
I’m receiving the error:
(48)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:8080
no listening sockets available, shutting down
AH00015: Unable to open logs
I’ve checked if maybe there is something else running on the 8080 port lsof -i TCP:8080
but it’s not.
I’ve checked which Apache is used (which apachectl
) and it seems to be the right one (/usr/local/bin/apachectl
)
No matter what port I’m trying to use, always there is an error that the address is already in use.
Does anyone has any idea how to fix this problem?
4
Answers
I was facing the same problem.
It appears that bindings to
INADDR_ANY (0.0.0.0)
fail.To circumvent the bind error, I changed in
/usr/local/etc/httpd/httpd.conf
the following line:to:
Afterwards, I could start apache without the bind error, using the following command:
I’ve also been facing this issue after my Mac was restarted (after a week of already using Big Sur). I had to completely uninstall the
httpd
from Brew, kill all the processes using port 80, re-install thehttpd
, changing thehttpd.conf
as Frank mentioned, and only then I could get it working (without the need forsudo
). :So in short, first change this line in
httpd.conf
to:Listen localhost:80
And then here is the list of command I ran:
If the service is not running. You can do:
brew services start http
Or:
/usr/local/opt/httpd/bin/httpd -k start
Please note, I already had a working system before this. For the full installation guidelines follow the amazing tutorial on getgrav. They deserve a lot of credit for such a complete tutorial and their support in the comments there!
P.S: Here is why you shouldn’t use
sudo
to starthttpd
.I had the same problem, but needed to run apache on port 80. First I got it working on 8080 with the solution above by @FrankStappers with:
Next I tried changing the port to 80 in both Listen and ServerName directives. Restarting left me with these errors:
Ultimately changing Listen and ServerName as follows fixed it:
The solution is documented in the Troubleshooting Non-Sudo httpd Services Start section of https://getgrav.org/blog/macos-bigsur-apache-multiple-php-versions
My solution:
brew services stop httpd
httpd.conf
maybe located in/usr/local/etc/httpd/httpd.conf
brew services start httpd