MacOS energy-saver setting
Mac OS include an Energy Saver feature that can cause hard drives connected in or to the computer to spin down after a period of inactivity. If Mac OS sends a command to spin down to an external drive, the drive may stop being detected by the computer.
To ensure that the Mac does not send a command to spin down your external drive, please see this article from Apple support.
Uncheck the Put the hard disk(s) to sleep when possible box in Energy Saver.