111

running brew services start mongodb-community which yields:

Bootstrap failed: 5: Input/output error
Error: Failure while executing; `/bin/launchctl bootstrap gui/501 /Users/<myUserName>/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist` exited with 5.

when I run launchctl load -w /Users/<myUserName>/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist

yields

Load failed: 5: Input/output error

I recently upgraded macOs to BigSur 11.5.2.

Ive uninstall and reinstalled homebrew and xcode.

dasqueel
  • 1,709
  • 2
  • 15
  • 16
  • https://www.reddit.com/r/MacOS/comments/kbko61/launchctl_broken/gpv2to1/ Didn't add this as an answer cuz it's not mine. This worked for me – Harsh Kumar Sep 02 '21 at 08:04
  • 1
    Ive tried this and I still get the same error. I wonder if I gave the correct inputs with the commands? Brew services should just work, as its the official way MongoDB says to start the service. – dasqueel Sep 07 '21 at 18:39

17 Answers17

117

try this

brew services restart <mongodb-community@4.4>

jtlz2
  • 7,700
  • 9
  • 64
  • 114
mari
  • 1,187
  • 1
  • 6
  • 2
39

I saw this issue with MySQL and the solution was my current profile was not the owner of my homebrew folder.

I had to change it because I have a second profile set up for another work space, but they share the same homebrew path.

I would suggest anyone who sees this error try running

sudo chown -R $(whoami) $(brew --prefix)/*

And then seeing if that will resolve it. Again I didn't have this issue with MongoDB, but I saw this exact error with MySQL when my profile didn't own the brew folder.

marcus.salinas
  • 627
  • 4
  • 8
  • 1
    After exploring a few options, this seems a lixely fix for me. In the interim, I got postgresql running using `sudo brew servies start postgresql` – Alex Booker Sep 24 '21 at 11:15
  • adding ```sudo``` before brew fixed it for me. – Jay Teli Jul 20 '22 at 20:10
  • Machine restart was also needed – Jay Teli Jul 20 '22 at 20:17
  • 1
    Some servers such as apache need be run as root to bind to the correct port. If you bind on a non-system protected port you may find better luck. My nginx server runs fine under my non-privileged user. `sudo` may in fact be the only way to start `httpd`. What's interesting is the seeming false positive errors you might get if you view `sudo brew services list` with and without `sudo`. This full feed was eye opening. – Richard Tyler Miles Aug 19 '22 at 01:16
  • 1
    [It's worth linking why and how `apache` does this](https://www.tenable.com/audits/items/CIS_Apache_HTTP_Server_2.4_Benchmark_v2.0.0_Level_1.audit:3e40bb6b17d51e608448449f08a3b496) to understand security considerations. – Richard Tyler Miles Aug 19 '22 at 01:24
  • 1
    thanks. I tried several ways but it doesnt work. this update work perfectly. thanks – Long Tran Oct 13 '22 at 02:41
  • 1
    I tried many other answers and only this one worked for me. I didn't restart the Mac to achieve it. – logoff Jan 30 '23 at 11:49
  • 1
    This seems to stop all the nonsense coming out of my terminal, thanks! – Purple_Kitten Feb 14 '23 at 16:57
37

I am able to run mongodb through homebrew. I believe this solved my issue:

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

followed by

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

dasqueel
  • 1,709
  • 2
  • 15
  • 16
16

Try this if you tried to restart your service, but it still doesn't work

  1. stop your service
brew services stop mongodb-community
  1. restart your macOS
  2. start your service again
brew services start mongodb-community
Pagorn
  • 532
  • 1
  • 5
  • 25
14

To see the real errors, you need to run the service without brew

I had a similar problem, but instead of mongodb, I could not start apache(httpd).

$ brew services start httpd                                                                                                                                                        
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/john/Library/LaunchAgents/homebrew.mxcl.httpd.plist` exited with 
5.
FAIL: 1

Unfortunately brew doesn't show the user what causes this error. At first I tried to use the tips from the answers in this thread, but neither reinstalling apache nor unload -w/load -w helped. I also found nothing in the brew logs. I decided to investigate apache itself. To do this I ran apache without brew:

$ /opt/homebrew/Cellar/httpd/2.4.51/bin/apachectl start
httpd: Syntax error on line 66 of /opt/homebrew/etc/httpd/httpd.conf: Cannot load /opt/homebrew/Cellar/php@5.6/5.6.40_3/lib/httpd/modules/libphp5.so into server: dlopen(/opt/homebrew/Cellar/php@5.6/5.6.40_3/lib/httpd/modules/libphp5.so, 0x000A): tried: '/opt/homebrew/Cellar/php@5.6/5.6.40_3/lib/httpd/modules/libphp5.so' (no such file), '/usr/local/lib/libphp5.so' (no such file), '/usr/lib/libphp5.so' (no such file)
FAIL: 1

Then it was finally clear what was the reason why httpd service was not starting. It turned out that after the php upgrade, the php version had changed and I forgot to write the new php version in the apache configuration file. I quickly fixed this and apache started up.

Volex
  • 633
  • 6
  • 16
9

I faced a similar problem with postgresql 11 and restarting the service did not help. The issue arose when my MacBook restarted abruptly.

After checking the ports and trying out all the possible solutions, I decided to look into the logs.

tail -n 100 /usr/local/var/log/postgresql@11.log

This gave me the last 100 lines of the log where I found this:

FATAL:  lock file "postmaster.pid" already exists
HINT:  Is another postmaster (PID 479) running in data directory "/usr/local/var/postgresql@11"?

Clearly, the issue was with postmaster.pid so I deleted it:

rm /usr/local/var/postgresql@11/postmaster.pid

Started the postgres service again:

brew services start postgresql@11

and voila! It worked.

mansoor.khan
  • 2,309
  • 26
  • 39
7

It seems that the mongodb-community is already started. So do restart it instead of starting, by the following command:

brew services restart mongodb-community
Md Aman Ullah
  • 486
  • 1
  • 5
  • 17
6

I had similar error in regard to postgres.

$ brew services start postgresql
Bootstrap failed: 5: Input/output error
Error: Failure while executing; `/bin/launchctl bootstrap gui/501 /Users/yrk/Library/LaunchAgents/homebrew.mxcl.postgresql.plist` exited with 5.

I've tried restart and it looked promising:

$ brew services restart postgres
Stopping `postgresql`... (might take a while)
==> Successfully stopped `postgresql` (label: homebrew.mxcl.postgresql)
==> Successfully started `postgresql` (label: homebrew.mxcl.postgresql)

But there still was a problem when trying to connect:

 $ psql -d postgres -U apiuser
psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory
    Is the server running locally and accepting connections on that socket?

Checking postgres log as mentioned by @mansoor.khan helped, in my case it was: tail /usr/local/var/log/postgres.log.

And the issue was clear:

$ tail /usr/local/var/log/postgres.log
2022-05-19 14:18:46.029 CEST [32374] FATAL:  database files are incompatible with server
2022-05-19 14:18:46.029 CEST [32374] DETAIL:  The data directory was initialized by PostgreSQL version 13, which is not compatible with this version 14.3.
2022-05-19 14:18:56.071 CEST [32676] FATAL:  database files are incompatible with server
2022-05-19 14:18:56.071 CEST [32676] DETAIL:  The data directory was initialized by PostgreSQL version 13, which is not compatible with this version 14.3.
2022-05-19 14:19:06.111 CEST [32885] FATAL:  database files are incompatible with server
2022-05-19 14:19:06.111 CEST [32885] DETAIL:  The data directory was initialized by PostgreSQL version 13, which is not compatible with this version 14.3.
2022-05-19 14:19:16.128 CEST [33102] FATAL:  database files are incompatible with server
2022-05-19 14:19:16.128 CEST [33102] DETAIL:  The data directory was initialized by PostgreSQL version 13, which is not compatible with this version 14.3.
2022-05-19 14:19:26.166 CEST [33434] FATAL:  database files are incompatible with server
2022-05-19 14:19:26.166 CEST [33434] DETAIL:  The data directory was initialized by PostgreSQL version 13, which is not compatible with this version 14.3.

Now the problem is: how to revert to previous version or upgrade old data to new version of postgres DB, but this is for another topic.

yrk
  • 350
  • 3
  • 8
1

run something like launchctl remove homebrew.mxcl.mongodb-community before the load command solved my problem

HelloThere
  • 840
  • 10
  • 18
1

I had a similar problem on mysql.

Error: Failure while executing; `/bin/launchctl bootstrap gui/501 /Users/gerd/Library/LaunchAgents/homebrew.mxcl.mysql.plist` exited with 5.

In my case the mysqld miss the osx network connection permission. After restart OSX it appear the network permissions dialog. I granted the permission to msqld and the problem was fixed!

Gerd
  • 2,265
  • 1
  • 27
  • 46
1

I faced the same problem. This commands helped me

brew uninstall rabbitmq
brew uninstall erlang
brew install rabbitmq
brew services restart rabbitmq
Zhazgul
  • 61
  • 6
1

I had this when upgrading from 4.4 to 5.0 and I suspect it’s similar for you. Lets assume you were upgrading 5.x to 6.x then the resolution would be ...

  1. check your mongo log, e.g.
vi /usr/local/var/log/mongodb/mongo.log
  1. Look for any errors relating to file/directory permissions and fix those, e.g. though I’m not quite sure whether ‘wheel’ or ‘admin’ is right.
sudo chown yourloginname:wheel thedirectory/*
  1. Roll back to your previous working version of mongo (e.g. 5.x)
  2. Start Mongo 5
  3. Start a Mongo Shell and type
db.adminCommand( { setFeatureCompatibilityVersion: "5.0" } ) 
  1. Check the logs to verify the database has detected 5.0
  2. Uninstall 5.x
  3. Re-install 6.x
  4. Restart / start 6.x

It should now work?

RobbiewOnline
  • 1,350
  • 1
  • 16
  • 36
1

You may run into this if the service is already running, but as another user.

For example, you may have run sudo brew services start example and are now running brew services info example. It tells you it's not running and you think "hm, it should be running" and enter brew services start example.

Potentially example is already bound to, say, port 7777 and now you ask for another program to be bound to the same port, leading to a failing service start.

In short: If you are binding to a port, check if the same service is already running as another user and bound to the same port.

GhostLyrics
  • 150
  • 5
1

restart

I mean restart the computer.

I tried everything written here, including uninstalling and reinstalling the mongo itself. After all the struggle, restarting computer solved the problem for me, somehow.

Kolom
  • 217
  • 1
  • 11
0

In my case, another httpd process was running on the Mac. Killed with monitor tool allowed me to start httpd.

Prescol
  • 615
  • 5
  • 12
0

Happened with redis. Realized there was a bind setting in the config, binding the server to an incorrect ip address.

Nic Nilov
  • 5,056
  • 2
  • 22
  • 37
0

I had the same issue after updating to macOS Ventura, after trying a lot of stuff that didn't work the problem seemed that homebrew didn't have xcode-select and had conflicts with the newly installed OS:

what solved the issue:

xcode-select --install

Then update brew packages:

brew upgrade MySQL

Start MySQL as usually with homebrew

brew services restart MySQL

Update homebrew on macos ventura