Skip to content

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.

4 min read

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.

ProgramWhyFix
mds, mds_stores, mdworkerSpotlight is indexing the driveWait a minute, or exclude the drive in Spotlight settings
QuickLookUIServiceA preview of a file on the driveClose Quick Look windows
backupdA Time Machine backup is runningLet it finish or skip it
Photos, Music, LightroomA library on the drive is openQuit the app
zsh, bashA Terminal tab is in the driveType cd ~ or close it
An app nameA document from the drive is openSave 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.

Read next