I got the following error when my MacBook abruptly restarted:
Bootstrap failed: 5: Input/output error
Error: Failure while executing; `/bin/launchctl bootstrap gui/503
/Users/mwal/Library/LaunchAgents/homebrew.mxcl.postgresql@11.plist`
exited with 5.
Here's what I tried to resolve the error:
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.