Managing macOS Background Services with Homebrew's brew services Command
Learn how to start, stop, restart, and inspect Homebrew‑installed background services using the brew services wrapper around launchctl, with verification steps and recovery tips.
12 Dec 2025, 20:37 UTC

Desired outcome
You want to start, stop, restart, and inspect a background daemon installed via Homebrew (for example, a database or web server) using the brew services wrapper around launchctl.
Prerequisites
- Homebrew installed (version 2.0 or newer). Run
brew --versionto confirm. - The formula you intend to manage ships a launchd plist. Most server‑side formulae (e.g.,
postgresql,mysql,redis) include one; GUI‑only formulae do not. - You have write permission to the appropriate LaunchAgents directory:
- For the default Homebrew prefix (
/usr/localon Intel or/opt/homebrewon Apple Silicon) user‑services go to~/Library/LaunchAgents. - If you installed Homebrew with
sudoor use a system‑wide prefix, services belong in/Library/LaunchDaemonsand you will need to run the commands withsudo.
Focused procedure
1. List available services
Run the following in a terminal (no special permissions needed for user services):
brew services list
The output shows each formula that provides a plist, its status (started, stopped, error), and the plist file location.
2. Start a service
Choose the formula you want to run, e.g., postgresql. Start it with:
brew services start postgresql
If your Homebrew installation requires root for system services, prefix the command with sudo:
sudo brew services start postgresql
3. Stop a service
brew services stop postgresql
4. Restart a service
brew services restart postgresql
5. View logs
To troubleshoot, fetch the service’s log:
brew services log postgresql
Alternatively, open Console.app and look for the plist label (e.g., homebrew.mxcl.postgresql).
Expected checks
- After starting, run
brew services listagain. The line forpostgresqlshould showstarted. - Verify the launchd job is loaded:
launchctl list | grep homebrew.mxcl.postgresqlYou should see a entry with a non‑zero PID.
- Confirm the service is reachable. For PostgreSQL, try:
psql -h localhost -U postgresIf you get a prompt, the daemon is accepting connections.
- No error messages should appear in the output of
brew services startor in the log.
Recovery options
- Inspect the log: If the service fails to start, run
brew services log postgresqland look for lines indicating the problem (e.g., missing data directory, port already in use). - Check dependencies: Ensure any required libraries or other formulae are installed (
brew install opensslfor PostgreSQL, etc.). - Restart: Sometimes a transient issue clears with
brew services restart postgresql. - Reinstall the formula: As a last resort, remove and reinstall the formula, which also regenerates the plist:
brew uninstall postgresql brew install postgresqlThen repeat the start procedure.
- Permission conflicts: Avoid mixing
sudoand non‑sudoinvocations for the same formula. Stick to one domain (user services in~/Library/LaunchAgentsor system services in/Library/LaunchDaemons) to prevent launchctl from reporting “Operation not permitted” errors.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.