>>> how to stop running service on osx. they start by it self on startup.: % lsof -n -iTCP | grep LISTEN
... ARDAgent 485 beatriz 9u IPv6 0xad5d9b755bc891eb 0t0 TCP *:net-assistant (LISTEN)
... ControlCe 515 beatriz 10u IPv4 0xad5d9b6bc244fa93 0t0 TCP *:afs3-fileserver (LISTEN)
... ControlCe 515 beatriz 13u IPv6 0xad5d9b755bc8442b 0t0 TCP *:afs3-fileserver (LISTEN)
... ControlCe 515 beatriz 16u IPv4 0xad5d9b6bc244da43 0t0 TCP *:commplex-main (LISTEN)
... ControlCe 515 beatriz 17u IPv6 0xad5d9b755bc858cb 0t0 TCP *:commplex-main (LISTEN)
... nginx 582 beatriz 6u IPv4 0xad5d9b6bc244a573 0t0 TCP *:http-alt (LISTEN)
... nginx 582 beatriz 7u IPv4 0xad5d9b6bc2447003 0t0 TCP *:http (LISTEN)
... php-fpm 590 beatriz 9u IPv4 0xad5d9b6bc243da43 0t0 TCP 127.0.0.1:cslistener (LISTEN)
... nginx 644 beatriz 6u IPv4 0xad5d9b6bc244a573 0t0 TCP *:http-alt (LISTEN)
... nginx 644 beatriz 7u IPv4 0xad5d9b6bc2447003 0t0 TCP *:http (LISTEN)
... Ollama 717 beatriz 4u IPv4 0xad5d9b6bc243ba93 0t0 TCP 127.0.0.1:49228 (LISTEN)
... mysqld 746 beatriz 18u IPv4 0xad5d9b6bc243c523 0t0 TCP 127.0.0.1:33060 (LISTEN)
... mysqld 746 beatriz 22u IPv4 0xad5d9b6bc2436573 0t0 TCP 127.0.0.1:mysql (LISTEN)
... php-fpm 758 beatriz 10u IPv4 0xad5d9b6bc243da43 0t0 TCP 127.0.0.1:cslistener (LISTEN)
... php-fpm 759 beatriz 10u IPv4 0xad5d9b6bc243da43 0t0 TCP 127.0.0.1:cslistener (LISTEN)
... Adobe\x20 769 beatriz 34u IPv4 0xad5d9b6bbffe4523 0t0 TCP 127.0.0.1:15292 (LISTEN)
... Adobe\x20 769 beatriz 40u IPv4 0xad5d9b6bbffd1a43 0t0 TCP 127.0.0.1:15393 (LISTEN)
... Adobe\x20 769 beatriz 46u IPv4 0xad5d9b6bbffd0fb3 0t0 TCP 127.0.0.1:16494 (LISTEN)
... Microsoft 795 beatriz 24u IPv6 0xad5d9b755bc82f8b 0t0 TCP [::1]:42050 (LISTEN)
... RouterApp 12922 beatriz 27u IPv4 0xad5d9b6bc2461a43 0t0 TCP 127.0.0.1:11833 (LISTEN)
... RouterApp 12922 beatriz 36u IPv4 0xad5d9b6bc245e573 0t0 TCP 127.0.0.1:11844 (LISTEN)
... ollama 31432 beatriz 3u IPv4 0xad5d9b6bc246cfb3 0t0 TCP 127.0.0.1:11434 (LISTEN)
Below is a “one‑size‑fits‑all” recipe for stopping any background service that macOS brings up automatically,
and for making sure it doesn’t come back the next time you log in or boot.
---
## 1. Find the job that owns the process
Every long‑running service on macOS is controlled by **launchd**.
The first step is to discover which *launchd* job (the “label”) is responsible for the process you see in
`lsof`.
```bash
# List all loaded jobs, then filter for the name you care about
sudo launchctl list | grep -i <name>
```
Examples (replace `<name>` with part of the service name, e.g. `nginx`, `mysqld`, `Arda`, etc.):
```bash
sudo launchctl list | grep -i nginx
# → 582 com.nginx
```
If you see a PID column, you can also kill the process immediately, but it will usually just respawn:
```bash
kill -9 <PID>
```
But that’s only a *temporary* stop – the launchd job will start it again.
---
## 2. Locate the `.plist` file for the job
Launch agents and daemons live in a few standard directories:
| Type | Path | Typical ownership |
|------|------|-------------------|
| System launch daemon | `/System/Library/LaunchDaemons` | `root` |
| System launch agent | `/System/Library/LaunchAgents` | `root` |
| Third‑party launch daemon | `/Library/LaunchDaemons` | `root` |
| Third‑party launch agent | `/Library/LaunchAgents` | `root` |
| User launch agent | `~/Library/LaunchAgents` | current user |
Use `sudo find /Library /System -name '*<label>*'` or `sudo find ~/Library -name '*<label>*'` to pinpoint the
file.
The label you saw in the `launchctl list` output is the same as the filename (usually
`com.company.service.plist`).
---
## 3. Stop the job *and* prevent it from restarting
### a. If the job is running as root (i.e. a *daemon*)
```bash
# (You may need to replace <path> with the exact plist location you found)
sudo launchctl bootout system <path> # macOS 12+ (Monterey)
sudo launchctl unload -w <path> # older macOS (≤ Big Sur)
```
### b. If the job is a user agent
```bash
# For macOS 12+ (Monterey)
launchctl bootout user/$(id -u) <path>
# For older macOS
launchctl remove <label>
```
> **Tip** – If you’re unsure which macOS version you’re on, run:
> ```bash
> sw_vers -productVersion
> ```
### c. If the job was installed by Homebrew
Homebrew keeps a small wrapper script in `~/Library/LaunchAgents` or `/Library/LaunchDaemons`.
Stop it with the high‑level command:
```bash
brew services stop <service_name> # e.g. brew services stop nginx
```
Homebrew will also set the plist’s `Disabled` key so the job won’t auto‑start again.
---
## 4. Verify the job is stopped
```bash
sudo launchctl list | grep -i <label>
# No output → job is unloaded
# Or double‑check that the port is no longer listening:
lsof -n -iTCP | grep LISTEN | grep -i <port>
```
---
## 5. Remove or keep the plist file
*If you want the service **permanently** gone* (be careful – some services are required by apps you might use
later):
```bash
sudo rm <path> # delete the .plist
```
*If you only want to stop it now but keep the file (e.g. for future re‑enable)*, just keep it in place –
launchd will ignore it while it’s unloaded.
---
## Common Services and Where They Live
| Service | Typical plist location | Notes |
|---------|------------------------|-------|
| **nginx** (Homebrew) | `/usr/local/opt/nginx/homebrew.mxcl.nginx.plist` | `brew services stop nginx` |
| **mysqld** (Homebrew) | `/usr/local/opt/mysql/homebrew.mxcl.mysql.plist` | `brew services stop mysql` |
| **php‑fpm** (Homebrew) | `/usr/local/opt/php@7.x/homebrew.mxcl.php-fpm.plist` | `brew services stop php` |
| **Ollama** (Homebrew) | `/usr/local/opt/ollama/homebrew.mxcl.ollama.plist` | `brew services stop ollama` |
| **Adobe** (Creative Cloud) | `/Library/LaunchAgents/com.adobe.CCUpdater.plist` | Usually tied to the CC app
|
| **Microsoft OneDrive** | `/Library/LaunchAgents/com.microsoft.OneDrive.plist` | `launchctl unload -w
/Library/LaunchAgents/...` |
| **ARDAgent / ControlCe** | often in `/Library/LaunchDaemons` | Third‑party business software |
| **RouterApp** | likely in `~/Library/LaunchAgents` | Check the exact filename |
---
## Quick‑Start Checklist
| Step | Command | What it does |
|------|---------|--------------|
| 1. List all jobs | `sudo launchctl list | grep -i <name>` | Find the job label |
| 2. Locate plist | `sudo find /Library /System -name '*<label>*'` | Get the exact path |
| 3. Stop the job | `sudo launchctl bootout system <path>` or `brew services stop <service>` | Immediately
stop it |
| 4. Verify | `lsof -n -iTCP | grep LISTEN | grep -i <port>` | Ensure port is free |
| 5. Optional: delete | `sudo rm <path>` | Remove the plist permanently |
---
### A Note on “Login Items”
If the service is *not* a launchd job but a classic “Login Item” (added via **System Settings → Users &
Groups → Login Items**), you can simply uncheck it there, or run:
```bash
osascript -e 'tell application "System Events" to delete (first login item whose name contains "<name>")'
```
---
## TL;DR
1. **Find** the launchd label (`sudo launchctl list | grep -i <name>`).
2. **Locate** the plist (`sudo find /Library /System -name '*<label>*'`).
3. **Unload** it (`sudo launchctl bootout system <path>` or `brew services stop <service>`).
4. **Delete** the plist if you never want it again (`sudo rm <path>`).
Follow those steps for any of the services you see listening on your Mac, and they’ll stop auto‑starting at
the next login or boot. Happy hacking!