Elastic Agent runs as an operating system service, so you start and stop it with systemd on Linux, launchd on macOS and the Service Control Manager on Windows. This page adds what the start and stop commands above leave out: restart and status commands, enabling the agent at boot, the built-in elastic-agent CLI, install and uninstall commands, and fixes for common errors, including a corrected Windows command.
Start Elastic Agent
# Mac
$ sudo launchctl load /Library/LaunchDaemons/co.elastic.elastic-agent.plist
# Linux
$ sudo service elastic-agent start
#Windows
$ Start-Service Elastic Agent
# Debian
$ sudo systemctl start elastic-agent
#RPM
$ sudo systemctl start elastic-agent
Code language: PHP (php)
Stop Elastic Agent
# Mac
$ sudo launchctl unload /Library/LaunchDaemons/co.elastic.elastic-agent.plist
# Linux
$ sudo service elastic-agent stop
#Windows
$ Stop-Service Elastic Agent
# Debian
$ sudo systemctl stop elastic-agent
$ sudo service elastic-agent stop
#RPM
$ sudo systemctl stop elastic-agent
$ sudo service elastic-agent stop
Code language: PHP (php)
How Elastic Agent runs on each platform
Elastic Agent is one agent that replaces separately installed Beats such as Filebeat and Metricbeat. It manages its components (including Beats-based inputs) by itself, so day-to-day you control a single service. How it is installed decides where it lives and which commands apply:
| Install method | Service manager | Service name | Install location |
|---|---|---|---|
Linux tar.gz + elastic-agent install | systemd | elastic-agent | /opt/Elastic/Agent |
| DEB or RPM package | systemd | elastic-agent | /usr/share/elastic-agent, config in /etc/elastic-agent |
macOS tar.gz + elastic-agent install | launchd | co.elastic.elastic-agent | /Library/Elastic/Agent |
| Windows zip/MSI + install | Service Control Manager | Elastic Agent | C:\Program Files\Elastic\Agent |
In the example above, the separate "Linux", "Debian" and "RPM" entries all control the same systemd unit. On any modern systemd distribution, sudo service elastic-agent start just passes the request to systemctl. Use systemctl directly so you get clearer errors and status output.
Corrected start and stop commands
The Windows commands above fail as written. Start-Service takes the service name as a single positional argument. Without quotes, PowerShell reads Elastic and Agent as two arguments and stops with *A positional parameter cannot be found that accepts argument 'Agent'*. Put the name in quotes and run the commands from an elevated (Run as Administrator) PowerShell window. The $ prompt is also a Unix convention: PowerShell shows PS>.
# Windows (elevated PowerShell)
PS> Start-Service "Elastic Agent"
PS> Stop-Service "Elastic Agent"
PS> Restart-Service "Elastic Agent"
PS> Get-Service "Elastic Agent"Code language: PHP (php)
On macOS, launchctl load and unload still work but are legacy subcommands. Current macOS releases use bootstrap and bootout with the system domain, and kickstart to restart:
# macOS: start (load the daemon)
sudo launchctl bootstrap system /Library/LaunchDaemons/co.elastic.elastic-agent.plist
# macOS: stop (unload the daemon)
sudo launchctl bootout system /Library/LaunchDaemons/co.elastic.elastic-agent.plist
# macOS: restart a loaded daemon
sudo launchctl kickstart -k system/co.elastic.elastic-agent
# macOS: check whether it is loaded and running
sudo launchctl print system/co.elastic.elastic-agent | grep -E 'state|pid'Code language: PHP (php)
Linux, for all install methods:
sudo systemctl start elastic-agent
sudo systemctl stop elastic-agent
sudo systemctl restart elastic-agent
sudo systemctl status elastic-agent
Enable Elastic Agent at boot
Running elastic-agent install from a tar.gz registers and enables the service for you. The DEB and RPM packages put the files in place but do not necessarily enable or start the service. After you enroll a package-installed agent, enable it explicitly:
sudo systemctl enable --now elastic-agent
systemctl is-enabled elastic-agent # expected: enabled
systemctl is-active elastic-agent # expected: activeCode language: PHP (php)
On Windows the installer sets the service to start automatically. To check, or to fix it if someone changed it:
PS> Get-Service "Elastic Agent" | Select-Object Name, Status, StartType
PS> Set-Service "Elastic Agent" -StartupType AutomaticCode language: JavaScript (javascript)
Built-in elastic-agent CLI commands
The service commands only start and stop the process. The elastic-agent binary talks to the running daemon and reports what it is actually doing. Run it as root or Administrator. For tar.gz installs the binary is also put on the PATH. If it is not found, call it by its full path inside the install directory.
| Command | What it does |
|---|---|
elastic-agent status | Shows overall health, the Fleet connection and the state of each component and unit |
elastic-agent status --output json | Same information in machine-readable form for scripts and monitoring |
elastic-agent inspect | Prints the effective configuration the agent is running, including policy received from Fleet |
elastic-agent diagnostics | Writes a zip archive of logs, configuration and state for troubleshooting or a support case |
elastic-agent restart | Restarts the agent daemon without going through the service manager |
elastic-agent version | Shows the binary version and, if reachable, the running daemon version |
elastic-agent enroll | Enrolls an already installed agent into Fleet |
elastic-agent upgrade <version> | Upgrades a standalone agent (Fleet-managed agents are upgraded from Fleet) |
elastic-agent uninstall | Removes the service and the installed files |
# Quick health check on Linux or macOS
sudo elastic-agent status
# Machine-readable status for scripts
sudo elastic-agent status --output json
# Collect a diagnostics bundle in the current directory
sudo elastic-agent diagnosticsCode language: PHP (php)
Note: The JSON field names and the format of the state value have changed between releases. Check the output of your own version before you build alerting on it.
Install, enroll and uninstall
Fleet-managed install from a tar.gz or zip archive. Copy the Fleet Server URL and enrollment token from Fleet > Add agent in Kibana:
# Linux / macOS, from the extracted archive directory
sudo ./elastic-agent install \
--url=https://fleet-server.example.com:8220 \
--enrollment-token=<ENROLLMENT_TOKEN>
# Windows, elevated PowerShell, from the extracted directory
PS> .\elastic-agent.exe install --url=https://fleet-server.example.com:8220 --enrollment-token=<ENROLLMENT_TOKEN>Code language: PHP (php)
Packages install first and enroll afterwards:
sudo elastic-agent enroll \
--url=https://fleet-server.example.com:8220 \
--enrollment-token=<ENROLLMENT_TOKEN>
sudo systemctl enable --now elastic-agentCode language: JavaScript (javascript)
To uninstall, use the method that matches the install. Archive installs use the agent's own uninstaller. Packages are removed with the package manager.
# Linux tar.gz install
sudo /opt/Elastic/Agent/elastic-agent uninstall
# macOS
sudo /Library/Elastic/Agent/elastic-agent uninstall
# Windows (elevated PowerShell)
PS> & "C:\Program Files\Elastic\Agent\elastic-agent.exe" uninstall
# DEB / RPM
sudo apt-get remove elastic-agent # Debian/Ubuntu
sudo dnf remove elastic-agent # RHEL/Fedora family
# If the agent policy has tamper protection enabled
sudo /opt/Elastic/Agent/elastic-agent uninstall --uninstall-token <TOKEN>Code language: PHP (php)
Common errors and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
Unit elastic-agent.service could not be found | The agent was run from the extracted archive but never installed as a service | Run sudo ./elastic-agent install ... from the archive directory |
A positional parameter cannot be found that accepts argument 'Agent' | Service name not quoted in PowerShell | Use Start-Service "Elastic Agent" |
| Access denied when controlling the service on Windows | PowerShell is not elevated | Reopen PowerShell with Run as Administrator |
elastic-agent status cannot connect to the daemon | The service is stopped or failed during startup | Start it, then check sudo journalctl -u elastic-agent -n 100 |
| Package-installed agent stops after a reboot | Service never enabled | sudo systemctl enable --now elastic-agent |
| Agent shows Offline or Unhealthy in Fleet | Service stopped, Fleet Server unreachable, or a failing integration | Run elastic-agent status locally and check network access to port 8220 |
| Uninstall refused | Tamper protection is on in the agent policy | Get the uninstall token from Fleet and pass --uninstall-token |
The agent writes detailed logs under its install directory, in a versioned data/elastic-agent-*/logs folder. On Linux, journalctl -u elastic-agent is most useful for failures that happen before the agent's own logging starts. When the cause is still unclear, elastic-agent diagnostics gathers these logs together with the running configuration.
Best practices
- Use
systemctl,launchctl bootstrap/bootoutand quoted PowerShell service names consistently in runbooks so commands are copy-paste safe. - Check
elastic-agent statusafter a restart. A running service does not mean that every integration is healthy. - For Fleet-managed agents, change configuration in the agent policy in Kibana, not by editing
elastic-agent.ymlon the host. Local edits are overridden by the policy. - Turn on tamper protection for endpoint security policies so local users cannot easily stop or remove the agent.
- Treat enrollment tokens as secrets. Do not commit them to repositories or leave them in shell history; pass them through your configuration management tool's secret store.
- Expect the host to appear offline in Fleet whenever you stop the service for maintenance, and tell whoever watches Fleet alerts.
For more on systemd service management and general server administration, see the Linux tutorials.
Frequently asked questions
How do I check if Elastic Agent is running?
Use sudo systemctl status elastic-agent on Linux, Get-Service "Elastic Agent" on Windows, or sudo launchctl print system/co.elastic.elastic-agent on macOS. To check health as well as whether the process is running, run sudo elastic-agent status.
How do I restart Elastic Agent?
Run sudo systemctl restart elastic-agent on Linux, Restart-Service "Elastic Agent" in elevated PowerShell on Windows, or sudo launchctl kickstart -k system/co.elastic.elastic-agent on macOS. The elastic-agent restart command also restarts the running daemon.
Why does Start-Service Elastic Agent fail in PowerShell?
The service name contains a space, so PowerShell treats Elastic and Agent as two separate arguments. Put the name in quotes, Start-Service "Elastic Agent", and run PowerShell as Administrator.
Where are Elastic Agent logs stored?
Logs are written under the install directory, for example /opt/Elastic/Agent on Linux, in a versioned data/elastic-agent-*/logs folder. On Linux, journalctl -u elastic-agent shows service startup errors, and elastic-agent diagnostics collects all logs into a single archive.
Do I still need Filebeat or Metricbeat if I use Elastic Agent?
Usually not. Elastic Agent runs the needed data collection components itself, based on the integrations in its policy, so you manage one agent instead of several Beats.
Related tutorials
- More Linux tutorials
- Red Hat EX342 Complete Home-Study Curriculum
- How to Login to Linux Server using Putty?
I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms.
I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services โ all in one place.
Explore Hospitals