LinuxCommandLibrary

brew-services

Manage Homebrew-installed services

TLDR

List all managed services for the current user

$ brew services
copy

List more information about all managed services
$ brew services info --all
copy

Start a service immediately and register it to launch at login (or boot)
$ brew services start [formula]
copy

Stop the service immediately and unregister it from launching at login (or boot)
$ brew services stop [formula]
copy

Stop (if necessary) and start the service immediately and register it to launch at login (or boot)
$ brew services restart [formula]
copy

Remove all unused services
$ brew services cleanup
copy

SYNOPSIS

brew services [list|run|start|stop|restart|cleanup] [options] [formula …]

PARAMETERS

--all, -a
    Apply operation to all matching services

--debug
    Enable debug output

--help, -h
    Show help message

--json[=v1]
    Output as JSON (list subcommand only)

--no-color
    Disable colored output

--verbose, -v
    Verbose details (list subcommand only)

--warp
    Wait for service readiness (macOS start/restart only)

DESCRIPTION

brew services is a Homebrew subcommand for managing background services (daemons) provided by installed formulas. It simplifies starting, stopping, restarting, listing, and debugging services, abstracting platform-specific details.

On macOS, it creates and manages LaunchAgent plist files in ~/Library/LaunchAgents/homebrew.mxcl.<formula>.plist, using launchctl to load/unload them. Services start automatically on user login.

On Linux (Homebrew on Linux or Linuxbrew), it generates systemd user unit files in ~/.config/systemd/user/homebrew-<formula>.service, controlled via systemctl --user. Requires a running user systemd instance (e.g., systemd --user socket activated).

Common use cases include databases (postgresql, mysql), caches (redis), and web servers. Install with brew install <formula>, then brew services start <formula>. Use run for foreground execution during development. Services run as the current user for security and simplicity—no sudo required.

It lists service status (started/stopped/error), supports JSON output, and cleans stale files. Not all formulas ship service definitions; some require manual setup.

CAVEATS

Runs user-level services only (no root). Formulas must provide service files. Linux needs systemctl --user enabled. Errors if service manager unavailable. Use cleanup for stale plists/units.

SUBCOMMANDS

list: Show running/stopped services.
run: Foreground execution.
start: Background start/load.
stop: Stop/unload.
restart: Stop then start.
cleanup: Remove dead service files.

SERVICE PATHS

macOS: ~/Library/LaunchAgents/homebrew.mxcl.<formula>.plist
Linux: ~/.config/systemd/user/homebrew-<formula>.service

HISTORY

Introduced in Homebrew 0.9.9 (February 2014) for macOS launchd support. Enhanced with JSON output and cleanup in later versions. Linux/systemd support added via Linuxbrew (2014), merged into core Homebrew by 2020.

SEE ALSO

brew(1), launchctl(8), systemctl(1)

Copied to clipboard