Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mac OS Big Sur - Homebrew Apache - 48)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:8080

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.

  1. So I have stopped the preinstalled Apache sudo apachectl stop
  2. Unloaded launcher sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null
  3. Updated the Homebrew
    • brew update
    • brew doctor
    • brew upgrade
  4. Installed the httpd again brew install httpd (installed successfully)
  5. 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?

like image 491
Jacek Koziol Avatar asked Nov 19 '20 12:11

Jacek Koziol


2 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:

Listen 8080

to:

Listen 127.0.0.1:8080

Afterwards, I could start apache without the bind error, using the following command:

sudo apachectl -k start
like image 93
FrankStappers Avatar answered Oct 07 '22 05:10

FrankStappers


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:

Listen 127.0.0.1:8080
ServerName localhost:8080

Next I tried changing the port to 80 in both Listen and ServerName directives. Restarting left me with these errors:

(13)Permission denied: AH00072: make_sock: could not bind to address 127.0.0.1:80
no listening sockets available, shutting down
AH00015: Unable to open logs

Ultimately changing Listen and ServerName as follows fixed it:

Listen 0.0.0.0:80
ServerName localhost

The solution is documented in the Troubleshooting Non-Sudo httpd Services Start section of https://getgrav.org/blog/macos-bigsur-apache-multiple-php-versions

like image 2
lbrucel Avatar answered Oct 07 '22 05:10

lbrucel