Western Digital external hard drive is constantly ejected I have a 1TB Western Digital external hard drive that I use for Time Machine backups, and recently my iMac has started to randomly eject the hard drive, preventing backups. It tends to happen while the display goes to sleep, but I have my Energy Saver settings set to not put the hard drives to sleep, and the computer is set to never go to sleep.

To correct the issue, I pull the USB cable on the drive and then re-attach it. I'm wondering if this is just a bad drive that I need to return or if this is some kind of larger issue.
Someone reported a similar issue on an Apple discussion forum:

I tried that but the drive will still eject itself randomly at times.
I contacted Western Digital about this and they say it might be a
problem with my USB cord. So they're going to send me a new one.
Has
anyone else had this problem and found that it was due to a faulty USB
3.0 (compatible with USB 2.0) cord?

Another poster in the same thread commented:

Sounds like disk is on the way out. I would move or backup all data on
it.

You should first back up that drive before anything else. Contact WD to see if they can send you a new USB cord. It's a good idea to run some diagnostics on the drive to confirm that there are no disk errors. Testing on another computer would also be a good idea to narrow down to see if the issue is isolated to your machine or the drive.
If the drive is failing, you'll need to return/exchange it.