34

Just tried accessing my localhost today, but it doesn't work. I worked yesterday, but I believe it's because my Mac crashed. I've tried started httpd again with brew services start httpd. This results in:

Bootstrap failed: 5: Input/output error Try re-running the command as root for richer errors. Error: Failure while executing; /bin/launchctl bootstrap gui/501 /Users/UserName/Library/LaunchAgents/homebrew.mxcl.httpd.plist exited with 5.

Have tried reinstalling httpd, but it still gives the same error. Any ideas what the cause can be?

1

13 Answers 13

69

Just thought I'd share what worked for me for anyone else still stuck...

It seemed I had a version of apache running which was stopping the brew version. (thought I'd removed the built in apache already!).

This also happened after my Mac crashed and got the exact same error message but I did:

Stop brew httpd service completely

brew services stop httpd   

Stop Mac Apache leftovers

sudo apachectl -k stop

Start brew httpd again

brew services start httpd

Started like a charm and solved my issue.

Sign up to request clarification or add additional context in comments.

6 Comments

Thank you, Wasted an hour trying to work out why my local server just stopped working, running sudo apachectl -k stop showed that I had a site configured in my httpd-vhost.conf that I had deleted in my sites folder in my last dev session. Warning: DocumentRoot [/Users/xxxxxx/Sites/xxxxxxxx/public_html] does not exist Deleting that entry, restarting the server and I'm back in business :)
@DerekOBrien Great to hear! Quick tip - you can also use command sudo apachectl configtest This will tell you if there's any issues with your current apache config without having to stop apache. Usually good to run this after any config changes or big changes to Sites directory.
@Fez thanks for this. httpd successfully starts but is stopped right away on its own. Anyone happens to know why? I got the same issue after a computer crash.
The solution works but the problem persists after every reboot.
@user3072843 - Likely due to your config having it auto load on startup. A possible solution would be to unload the default mac apache so that it does not auto load. That way you're left with only Brew httpd running. Of course I don't know what version of anything you're running but see this example of unload: superuser.com/a/986792
|
66

I had the same problem after I upgraded to macOS Monterey. But I solved my issue via these commands.

Unload homebrew.mxcl.httpd.plist

launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.httpd.plist

And then load it again:

launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.httpd.plist

After that I used this command to start httpd again.

brew services start httpd

2 Comments

I was having the same issues with Nginx. I had to do @Dave Myburgh's solution followed by this to get it working (replacing httpd for nginx in file paths, etc).
This weird! it also fixed "httpd error 256 root" error! thanks.
12

I had the same problem after any Restart my Macbook. I'm using Macbook Air m1 and Monterey OS version.

I have solved my problem with these 4 command

At first run:

sudo apachectl -k stop

After that run these three command: (note: do not run as sudo)

launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.httpd.plist

launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.httpd.plist

brew services start httpd

Then you can see run services with command below:

brew services list

Comments

9

After trying ALL the solutions proposed all over the place, what finally did it for me was changing the owner of the log files in /usr/local/var/log/httpd to my user, instead of root.

sudo chown [username] *

This took me hours to figure out, sadly - I even removed and reinstalled httpd (which was actually a good thing, because there was a n older version's keg knocking around back there).

1 Comment

Saved my day too, many thanks! My logs are in /opt/homebrew/var/log/httpd/ though.
3

So after trying a lot of things, this seemed to work:

Trying what Volex suggests here (brew services. Cant start service. get "Bootstrap failed: 5: Input/output error") gave me a more precise error message.

The new error message led me to this: apache doesn't work after upgrade of macOs Sierra brew reinstall apr-util fixed the problem.

Comments

2

After having tried all the solutions in this post without success, I finally found the solution that worked for me.

I don't know how, I don't why but the owner of the log files was root. The fact is the httpd service does NOT start in sudo... #deadlock.

I just changed the owner of the access_log and error_log files from /usr/local/var/log/httpd :

sudo chown <my_regular_user> access_log
sudo chown <my_regular_user> error_log

re-install httpd with brew :

brew reinstall httpd

execute a automatic-suggested command :

sudo rm -rf /usr/local/Cellar/httpd/2.4.57.reinstall

and finaly restart my httpd service

brew services restart httpd

1 Comment

i found this is the most efficient way, it solved the issue in less than 3 minutes. thanks.
1

for me I got quite same problem once I have tried to start postgresql forgetting that I have already started it, after stopping it and started it again it worked

user@users-MacBook-Pro ~ % brew services start postgresql
Warning: Use postgresql@14 instead of deprecated postgresql
Bootstrap failed: 5: Input/output error
Try re-running the command as root for richer errors.
Error: Failure while executing; `/bin/launchctl bootstrap gui/501 /Users/user/Library/LaunchAgents/[email protected]` exited with 5.
user@users-MacBook-Pro ~ % brew services stop postgresql 
Warning: Use postgresql@14 instead of deprecated postgresql
Stopping `postgresql@14`... (might take a while)
==> Successfully stopped `postgresql@14` (label: homebrew.mxcl.postgresql@14)
user@users-MacBook-Pro ~ % 
user@users-MacBook-Pro ~ % brew services start postgresql
Warning: Use postgresql@14 instead of deprecated postgresql
==> Successfully started `postgresql@14` (label: homebrew.mxcl.postgresql@14)
user@users-MacBook-Pro ~ % 

Comments

1

In my case, because I'm in an Apple Silicon Mac, I had to reinstall Apache:

brew uninstall httpd
brew install httpd

And check the paths of the php_module in httpd.conf file:

The path I was using was for the previous Intel based Macs:

LoadModule php_module /usr/local/opt/php/lib/httpd/modules/libphp.so

I've changed this part of the path from /usr/local/ to /opt/homebrew/:

LoadModule php_module /opt/homebrew/opt/php/lib/httpd/modules/libphp.so

Comments

0

In some cases will help restart HTTPD.

brew services restart httpd

It happens to me when the PC crashes for some reason and httpd is running, but localhost is "down". Or you can stop httpd and restart PC. Then start httpd and it's ok.

Comments

0

Deleting access_log and error_log in the log directory may help you reproduce the problem as sometimes those files are not writable.

After deleting them, those files will be created by the user and the error will be logged there.

Comments

0

For me, it's not a problem with plist file.

I was:

  • Try to run the command to make httpd run in background, it will throw some useful messages:

/opt/homebrew/opt/httpd/bin/httpd -D FOREGROUND

(48)Address already in use: AH00072: make_sock: could not bind to address [::]:443 (48)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:443

  • So 443 port conflict issue. You can check by:

sudo lsof -i:443

  • Then it resolved after :443 was killed or changed to a different port.

The key here is to run the command to make httpd run in background to get more clearer information for this kind of error.

Comments

0

This happened to me after my system unexpectedly crashed, and seems like apache got messed up. I think there was another httpd running on my computer when the system got up.


First, I restarted computer once again, properly. this changed the httpd status that I was getting with brew services list from stopped to error.

After that I check the port 80 and found the unwanted httpd processes:

sudo lsof -i :80

I found another apache running on this port, multiple PIDs. I killed all PIDs related to httpd:

sudo kill -9 {yourPID1} {yourPID2} {yourPID3} {yourPID4} {yourPID5 {yourPID6}

After that I restarted the httpd:

brew services restart httpd

After this I checked the httpd and it was up and running properly:

brew services list 

Comments

-1

I had to do the above fixes plus one other thing:

What happened: I force restarted my computer and after that "brew services start httpd" would automatically go into the "stopped" state. Ran through all the steps above but then encountered an issue where there were no active httpd instances but when I tried to launch/restart I got "httpd (pid 789) already running." <- this prevented the fixes from taking effect because it was holding unto a pid.

What worked: Ran sudo pkill -9 httpd and deleted /opt/homebrew/var/run/httpd/httpd.pid

1 Comment

The downvote is not helpful as this happened to me again and this exactly solved the issue in less than 10 seconds.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.