Appium can't find connected device after a while

Note: This is different from the issue here: Could not find a connected Android device because that issue was on a Windows machine. I am on OS X.

Normally, the computer can find it, but after a few hours when running a test, the appium server log says “error: device ‘XXXXXX’ not found”. But when I use the command “adb devices” the device shows up. Resetting the adb server does not help. The only thing that works is turning developer options on and off, but the issue resurfaces again a few hours later.