I am creating this question because this problem caused me 2 weeks of headache, and I found many other users online who experienced the same issue and were unable to find a solution.
Computer
M1 macbook running Sonoma or Monterey. This may affect other Apple Silicon macbooks as well.
Background
I installed homebrew and used this to install httpd and php. Prior to any configuration, I ran brew services start httpd
to test this out. Under normal circumstances, you can then visit localhost:8080 which should show a blank page with It Works!
In my case, it showed that the page could not be reached.
A major symptom of this issue is that the error_log will be showing outdated logs or no logs at all which causes difficulties when searching for the solution.
Troubleshooting
I ran brew services list
which showed that httpd was experiencing Error 256:
brew services list
Name Status User File
httpd error 256 georgeciesinski ~/Library/LaunchAgents/homebrew.mxcl.httpd.plist
Checking Error Log
I checked the error log by running:
tail -f /opt/homebrew/var/log/httpd/error_log
As I mentioned earlier, this specific problem is caused by httpd being unable to access the error log. This results in log messages showing outdated logs from hours ago even if you ran brew services start httpd
minutes before. It may also show no logs at all.
Failed Solutions
I tried many things to fix this problem before finding the working solution.
- Starting Apache with
sudo apachectl start
- Checking
which -a httpd
I have installed which showed the brew and apple installations - Searching which config is used by httpd
brew reinstall httpd
andbrew reinstall php