I have a Mac which I connect to using Screen Sharing to log in and start a video playing. Since upgrading to El Capitan, when I quit the screen sharing client, the screen on the remote machine turns off. How do I stop this from happening, while still having the screen turn off normally after a few minutes of inactivity?
5 Answers
Run this command in the terminal to fix the external screen going blank on VNC disconnect. Works with Sierra OS.
sudo defaults write /Library/Preferences/com.apple.RemoteManagement RestoreMachineState -bool NO
More context from jabenninghoff on GitHub:
In newer versions of macOS, screen sharing will automatically re-lock the screen when you disconnect if it was locked when you first connected.
Under System Preferences > Sharing, use “Remote Management” instead of “Screen Sharing”, as shown here:
As far as I can tell, everything else works the same but the screen no longer turns off when you disconnect a Screen Sharing connection.
edited to add: this is under 10.11.3
To be clear - the top-rated solution here alone from colo2100cent does not solve the problem if you're connecting to a MacBook with the lid closed (tested using a mid 2011 MacBook Air running Sierra - VNC disconnect required opening the lid and a physical button press to wake it up), but works fine if you're using a desktop based Mac like a Mac mini or an iMac. A display must be connected externally for this to work on a MacBook, but this is wasteful if it's being stored in a closet as a server or otherwise not being physically accessed.
What solved the problem for me was executing the command in colo2100cent's answer:
sudo defaults write /Library/Preferences/com.apple.RemoteManagement RestoreMachineState -bool NO
while also having a headless ghost display connected to the miniDP port, purchased for about 10 bucks. It tricks your MacBook into thinking there's a monitor connected at all times but does not require a monitor. Works like a charm - no more sleeping after VNC disconnect.
-
1Like @fitzroy pointed out in the other answer, this only works if the display (either real or fake) is plugged in during boot.– xiayJul 1, 2021 at 22:06
-
1Also for anyone who is curious, I used
Amphetamine
to keep the Macbook from sleep. Otherwise it won't respond to VNC in the first place once lid is closed.Amphetamine
could not deal with the VNC disconnection sleep though.– xiayJul 1, 2021 at 22:07 -
This worked when I needed to unlock a machine remotely running Monterey and didn't want to re-lock after I closed the connection.– nvahalikMay 8 at 23:27
I also have this issue (2012 Mac running El Capitan 10.11.5). I did not have this issue on my 2007 Mac Mini running 10.6.8 with a similar configuration (except using DVI instead of HDMI). When I close Mac screensharing or TouchPad on iOS, or switch iOS apps or lock the phone, the Mac Mini turns off external video.
The workaround I've found is: Hit pause / play on the Apple Remote (the physical infrared remote — not an app) after starting the video, before closing screensharing. Then you should be able to close screensharing and the screen will stay on. I've also done this with the Apple bluetooth mouse and it works as well.
You can also accomplish this by waking the Mac Mini with the remote before initiating screensharing, if you remember. Annoying though since it will often open and start playing iTunes.
The Mac just seems to need some input from a physical device (mouse or remote) after waking to prevent it putting the screen back to sleep.
Going to try the Remote Management checkbox also to see if that helps.
I solved this by restarting the Mac with the display (the TV) already ON.
If starting the Mac with the display off, either using Remote Management or Screen Sharing will result in the display turning off after disconnecting the VNC client.