WD passport connects and disconnects constantly from mac

I have a WD 4tb Passport for my mac and all of a sudden it connects and disconnects constantly from my Mac. Ive looked online and several people over the years have had the same problem with different drives. Anyone know how to fix this problem?

I had a similar issue.
This has been solved by updating macok to Mojave.
Hope it will help you too.