The disk wasn't ejected because one or more programs may be using it: how to find which
macOS refuses to eject a drive but will not say what is using it. One command names the program, and here is what to do about each common one.
You click Eject and macOS says The disk wasn't ejected because one or more programs may be using it. Pulling the cable out anyway risks damaging files that were being written. Finding the program takes seconds.
Find the program
lsof +f -- /Volumes/YourDrive 2>/dev/null | awk 'NR==1 || !seen[$1]++'Replace YourDrive with the drive's name as it appears in Finder. Each line starts with a program name.
| Program | Why | Fix |
|---|---|---|
mds, mds_stores, mdworker | Spotlight is indexing the drive | Wait a minute, or exclude the drive in Spotlight settings |
QuickLookUIService | A preview of a file on the drive | Close Quick Look windows |
backupd | A Time Machine backup is running | Let it finish or skip it |
Photos, Music, Lightroom | A library on the drive is open | Quit the app |
zsh, bash | A Terminal tab is in the drive | Type cd ~ or close it |
| An app name | A document from the drive is open | Save and close it |
If nothing is listed
Try Eject again after a few seconds. macOS then usually offers Force Eject. That is safe if you have closed everything you were working on. Logging out and back in releases anything left over.
Stop it happening
- Keep drives you plug in briefly out of Spotlight: System Settings, Spotlight, Search Privacy, add the drive.
- Quit apps whose library lives on the drive before ejecting.
If files on the drive keep ending up damaged, see Disk Utility First Aid failed.
Related: Erase process has failed on Mac and Disk Not Ejected Properly on Mac.
Common questions
How do I find what program is using my external drive on a Mac?
Run lsof +f -- /Volumes/YourDrive in Terminal. The first column of each line is the program using the drive.
Is it safe to force eject a drive on a Mac?
Yes, once you have closed any files you were working on. Forcing it while something is still writing can damage those files.
Why does Spotlight stop my drive ejecting?
Spotlight indexes new drives in the background. Wait for it, or add the drive to Spotlight's Search Privacy list.