Preventing server sleep during streaming?



Is there a setting somewhere to tell the Plex server to send a “do not sleep” message to the Energy Saver process on the Mac? My Mac server is set to sleep on idle, but it’s sleeping during streaming to a client. Not fun when you’re in the middle of watching something and it disconnects.

Thanks in advance.


Unless this documentation is outdated, this is what Plex server should probably be doing to prevent sleep while streaming.

"Applications have a chance to prevent sleep by calling IOCancelPowerChange”

Can one of the devs check for this and then file a bug with Apple if it’s not working?


This apple support page may assist. Some earlier model Macs have this issue, I have a more recent model now and have no issues running High Sierra. Then again others have had issues with remote access but that’s another story.

If this does not help you can try the following suggestions.


This isn’t a problem with the Mac — it’s a problem with Plex server. Other services keep the Mac awake while they are active. I’m not setting the server to “never sleep” — this is 2017. That’s the point of the “Wake for network access” setting in your screenshot.


Well to answer you I’m using the public release not the “pass” release and have no issue. So if you feel so strongly it’s not a Apple issue roll back. You will need to change your PMS settings to “Public” and manually install the public release. When it’s fixed you can update again. As for 2017 that finished a fortnight ago and I do not understand your reference to the issue in that vain.

If you would like to elaborate on error messages or behavior during your issue it may relate to other known problems. What happens with your stated disconnect. It is strange no one else has chimed in with similar issues in the discussion.


Thanks. I’ll give that a try. And yep, 2017 is over. Time flies!


So I used the pmset terminal command to check, and Plex is registering as “ PreventUserIdleSystemSleep” while streaming. I’ll do some more digging.

pid 1407(Plex Media Server): 00:00:08 PreventUserIdleSystemSleep named: "PreventUserIdleDisplaySleep"


This maybe the problem. recently i was having issues during streaming and put it down to other processes. Removed Spotlight indexing from PLEX storage drives and stopped Automatic backup with time machine.


So I did some more digging, and I found that streaming from iTunes to an Apple TV or another iTunes client sets “NetworkClientActive” mode on the server and the Mac does not go to sleep during the stream. Plex streaming uses “PreventUserIdleSystemSleep”. iTunes keeps the Mac awake during stream, Plex server does not. Mounting a file server from the same mac also uses “NetworkClientActive” and also keeps the mac from sleeping.

It could be a bug with macOS 10.13.2 and PreventUserIdleSystemSleep. We’ll see what 10.13.3 does (should be out soon) and I will follow up again.

I’m surprised no other Mac users have reported this. I guess most people aren’t using a mac as a server, or are keeping their server from sleeping, or it has something to do with using older mac hardware as the server.


Oh look…

So it’s not just me. These users gave up and rolled their own solution through a background script. I’m still having the same issue under 10.13.2. The issue is definitely related to “Wake On Lan” — the Mac wakes up when a Plex client makes a request, then the server starts to stream, the server makes the PreventUserIdleSystemSleep assertion, then the Mac still goes to sleep when it hits the sleep on idle timer (in spite of the assertion and the open network connection).

Might be worth switching Plex to the “NetworkClientActive” assertion since this is what iTunes uses during streaming.


Also possibly related:

"This assertion does not put the system into Dark Wake.”

So it sounds to me that would mean it wakes, but this assertion won’t keep it awake. Which would mean the Plex server is using the wrong call here. It should likely use “NetworkClientActive” like iTunes, SMB, and other network-based services or “PreventSystemSleep”” while streaming. It should of course release the assertion when clients are no longer streaming. This would allow the server to go back to sleep on idle, and in turn the server can be re-awakened by a streaming client through Bonjour sleep proxy and Wake On Lan.

“When asserted and set to level kIOPMAssertionLevelOn, the system will prefer to enter the Dark Wake state, or remain in Dark Wake if already there, rather than go to sleep.”